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 @@ -74,7 +74,6 @@ import (
74
74
"code.gitea.io/gitea/routers/api/v1/user"
75
75
76
76
"github.com/go-macaron/binding"
77
- "github.com/go-macaron/cors"
78
77
macaron "gopkg.in/macaron.v1"
79
78
)
80
79
@@ -501,12 +500,6 @@ func RegisterRoutes(m *macaron.Macaron) {
501
500
m .Get ("/swagger" , misc .Swagger ) //Render V1 by default
502
501
}
503
502
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
-
510
503
m .Group ("/v1" , func () {
511
504
// Miscellaneous
512
505
if setting .API .EnableSwagger {
@@ -852,7 +845,7 @@ func RegisterRoutes(m *macaron.Macaron) {
852
845
m .Group ("/topics" , func () {
853
846
m .Get ("/search" , repo .TopicSearch )
854
847
})
855
- }, handlers ... )
848
+ }, securityHeaders (), context . APIContexter (), sudo () )
856
849
}
857
850
858
851
func securityHeaders () macaron.Handler {
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import (
38
38
"github.com/go-macaron/binding"
39
39
"github.com/go-macaron/cache"
40
40
"github.com/go-macaron/captcha"
41
+ "github.com/go-macaron/cors"
41
42
"github.com/go-macaron/csrf"
42
43
"github.com/go-macaron/i18n"
43
44
"github.com/go-macaron/session"
@@ -947,9 +948,14 @@ func RegisterRoutes(m *macaron.Macaron) {
947
948
m .Get ("/swagger.v1.json" , templates .JSONRenderer (), routers .SwaggerV1Json )
948
949
}
949
950
951
+ var handlers []macaron.Handler
952
+ if setting .EnableCORS {
953
+ handlers = append (handlers , cors .CORS (setting .CORSConfig ))
954
+ }
955
+ handlers = append (handlers , ignSignIn )
950
956
m .Group ("/api" , func () {
951
957
apiv1 .RegisterRoutes (m )
952
- }, ignSignIn )
958
+ }, handlers ... )
953
959
954
960
m .Group ("/api/internal" , func () {
955
961
// 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