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 @@ -75,7 +75,6 @@ import (
7575 "code.gitea.io/gitea/routers/api/v1/user"
7676
7777 "gitea.com/macaron/binding"
78- "gitea.com/macaron/cors"
7978 "gitea.com/macaron/macaron"
8079)
8180
@@ -502,12 +501,6 @@ func RegisterRoutes(m *macaron.Macaron) {
502501 m .Get ("/swagger" , misc .Swagger ) //Render V1 by default
503502 }
504503
505- var handlers []macaron.Handler
506- if setting .EnableCORS {
507- handlers = append (handlers , cors .CORS (setting .CORSConfig ))
508- }
509- handlers = append (handlers , securityHeaders (), context .APIContexter (), sudo ())
510-
511504 m .Group ("/v1" , func () {
512505 // Miscellaneous
513506 if setting .API .EnableSwagger {
@@ -853,7 +846,7 @@ func RegisterRoutes(m *macaron.Macaron) {
853846 m .Group ("/topics" , func () {
854847 m .Get ("/search" , repo .TopicSearch )
855848 })
856- }, handlers ... )
849+ }, securityHeaders (), context . APIContexter (), sudo () )
857850}
858851
859852func securityHeaders () macaron.Handler {
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import (
4141 "gitea.com/macaron/binding"
4242 "gitea.com/macaron/cache"
4343 "gitea.com/macaron/captcha"
44+ "gitea.com/macaron/cors"
4445 "gitea.com/macaron/csrf"
4546 "gitea.com/macaron/i18n"
4647 "gitea.com/macaron/macaron"
@@ -951,9 +952,14 @@ func RegisterRoutes(m *macaron.Macaron) {
951952 m .Get ("/swagger.v1.json" , templates .JSONRenderer (), routers .SwaggerV1Json )
952953 }
953954
955+ var handlers []macaron.Handler
956+ if setting .EnableCORS {
957+ handlers = append (handlers , cors .CORS (setting .CORSConfig ))
958+ }
959+ handlers = append (handlers , ignSignIn )
954960 m .Group ("/api" , func () {
955961 apiv1 .RegisterRoutes (m )
956- }, ignSignIn )
962+ }, handlers ... )
957963
958964 m .Group ("/api/internal" , func () {
959965 // 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