File tree 2 files changed +8
-9
lines changed
2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,6 @@ import (
75
75
"code.gitea.io/gitea/routers/api/v1/user"
76
76
77
77
"gitea.com/macaron/binding"
78
- "gitea.com/macaron/cors"
79
78
"gitea.com/macaron/macaron"
80
79
)
81
80
@@ -502,12 +501,6 @@ func RegisterRoutes(m *macaron.Macaron) {
502
501
m .Get ("/swagger" , misc .Swagger ) //Render V1 by default
503
502
}
504
503
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
-
511
504
m .Group ("/v1" , func () {
512
505
// Miscellaneous
513
506
if setting .API .EnableSwagger {
@@ -853,7 +846,7 @@ func RegisterRoutes(m *macaron.Macaron) {
853
846
m .Group ("/topics" , func () {
854
847
m .Get ("/search" , repo .TopicSearch )
855
848
})
856
- }, handlers ... )
849
+ }, securityHeaders (), context . APIContexter (), sudo () )
857
850
}
858
851
859
852
func securityHeaders () macaron.Handler {
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import (
41
41
"gitea.com/macaron/binding"
42
42
"gitea.com/macaron/cache"
43
43
"gitea.com/macaron/captcha"
44
+ "gitea.com/macaron/cors"
44
45
"gitea.com/macaron/csrf"
45
46
"gitea.com/macaron/i18n"
46
47
"gitea.com/macaron/macaron"
@@ -951,9 +952,14 @@ func RegisterRoutes(m *macaron.Macaron) {
951
952
m .Get ("/swagger.v1.json" , templates .JSONRenderer (), routers .SwaggerV1Json )
952
953
}
953
954
955
+ var handlers []macaron.Handler
956
+ if setting .EnableCORS {
957
+ handlers = append (handlers , cors .CORS (setting .CORSConfig ))
958
+ }
959
+ handlers = append (handlers , ignSignIn )
954
960
m .Group ("/api" , func () {
955
961
apiv1 .RegisterRoutes (m )
956
- }, ignSignIn )
962
+ }, handlers ... )
957
963
958
964
m .Group ("/api/internal" , func () {
959
965
// 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