aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorTamal Saha <tamal@appscode.com>2019-08-26 04:33:06 -0700
committerAntoine GIRARD <sapk@users.noreply.github.com>2019-08-26 13:33:06 +0200
commit6b3f52fe5f7db5b3122cc8481ab8fed83e273fde (patch)
tree9f5701c987e8d9972754ddfbeae287dfcb13e9c4 /routers/api
parent5409dec8fd29dfb7fcd7c0afb8a2d9682abc48b1 (diff)
downloadgitea-6b3f52fe5f7db5b3122cc8481ab8fed83e273fde.tar.gz
gitea-6b3f52fe5f7db5b3122cc8481ab8fed83e273fde.zip
Run CORS handler first for /api routes (#7967)
Signed-off-by: Tamal Saha <tamal@appscode.com>
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/api.go9
1 files changed, 1 insertions, 8 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 69dfc89378..64c4b47a64 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -75,7 +75,6 @@ import (
"code.gitea.io/gitea/routers/api/v1/user"
"gitea.com/macaron/binding"
- "gitea.com/macaron/cors"
"gitea.com/macaron/macaron"
)
@@ -502,12 +501,6 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/swagger", misc.Swagger) //Render V1 by default
}
- var handlers []macaron.Handler
- if setting.EnableCORS {
- handlers = append(handlers, cors.CORS(setting.CORSConfig))
- }
- handlers = append(handlers, securityHeaders(), context.APIContexter(), sudo())
-
m.Group("/v1", func() {
// Miscellaneous
if setting.API.EnableSwagger {
@@ -853,7 +846,7 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Group("/topics", func() {
m.Get("/search", repo.TopicSearch)
})
- }, handlers...)
+ }, securityHeaders(), context.APIContexter(), sudo())
}
func securityHeaders() macaron.Handler {