File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,6 @@ import (
7474 "code.gitea.io/gitea/routers/api/v1/user"
7575
7676 "github.com/go-macaron/binding"
77- "github.com/go-macaron/cors"
7877 macaron "gopkg.in/macaron.v1"
7978)
8079
@@ -501,12 +500,6 @@ func RegisterRoutes(m *macaron.Macaron) {
501500 m .Get ("/swagger" , misc .Swagger ) //Render V1 by default
502501 }
503502
504- var handlers []macaron.Handler
505- if setting .EnableCORS {
506- handlers = append (handlers , cors .CORS (setting .CORSConfig ))
507- }
508- handlers = append (handlers , securityHeaders (), context .APIContexter (), sudo ())
509-
510503 m .Group ("/v1" , func () {
511504 // Miscellaneous
512505 if setting .API .EnableSwagger {
@@ -852,7 +845,7 @@ func RegisterRoutes(m *macaron.Macaron) {
852845 m .Group ("/topics" , func () {
853846 m .Get ("/search" , repo .TopicSearch )
854847 })
855- }, handlers ... )
848+ }, securityHeaders (), context . APIContexter (), sudo () )
856849}
857850
858851func securityHeaders () macaron.Handler {
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import (
3838 "github.com/go-macaron/binding"
3939 "github.com/go-macaron/cache"
4040 "github.com/go-macaron/captcha"
41+ "github.com/go-macaron/cors"
4142 "github.com/go-macaron/csrf"
4243 "github.com/go-macaron/i18n"
4344 "github.com/go-macaron/session"
@@ -947,9 +948,14 @@ func RegisterRoutes(m *macaron.Macaron) {
947948 m .Get ("/swagger.v1.json" , templates .JSONRenderer (), routers .SwaggerV1Json )
948949 }
949950
951+ var handlers []macaron.Handler
952+ if setting .EnableCORS {
953+ handlers = append (handlers , cors .CORS (setting .CORSConfig ))
954+ }
955+ handlers = append (handlers , ignSignIn )
950956 m .Group ("/api" , func () {
951957 apiv1 .RegisterRoutes (m )
952- }, ignSignIn )
958+ }, handlers ... )
953959
954960 m .Group ("/api/internal" , func () {
955961 // package name internal is ideal but Golang is not allowed, so we use private as package name.
You can’t perform that action at this time.
0 commit comments