Skip to content

Commit ad68022

Browse files
committed
fix(CORS): CORS on git smart http protocol can not work. fixes go-gitea#16350
1 parent e01b782 commit ad68022

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

routers/web/web.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ func RegisterRoutes(m *web.Route) {
752752
m.Post("/delete", repo.DeleteMilestone)
753753
}, context.RepoMustNotBeArchived(), reqRepoIssuesOrPullsWriter, context.RepoRef())
754754
m.Group("/pull", func() {
755-
m.Post("/{index}/target_branch", repo.UpdatePullRequestTarget)
755+
m.Post("/{index}/target_branch", CorsHandler(), repo.UpdatePullRequestTarget)
756756
}, context.RepoMustNotBeArchived())
757757

758758
m.Group("", func() {
@@ -1006,17 +1006,17 @@ func RegisterRoutes(m *web.Route) {
10061006
}, ignSignInAndCsrf, lfsServerEnabled)
10071007

10081008
m.Group("", func() {
1009-
m.Post("/git-upload-pack", repo.ServiceUploadPack)
1010-
m.Post("/git-receive-pack", repo.ServiceReceivePack)
1011-
m.Get("/info/refs", repo.GetInfoRefs)
1012-
m.Get("/HEAD", repo.GetTextFile("HEAD"))
1013-
m.Get("/objects/info/alternates", repo.GetTextFile("objects/info/alternates"))
1014-
m.Get("/objects/info/http-alternates", repo.GetTextFile("objects/info/http-alternates"))
1015-
m.Get("/objects/info/packs", repo.GetInfoPacks)
1016-
m.Get("/objects/info/{file:[^/]*}", repo.GetTextFile(""))
1017-
m.Get("/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", repo.GetLooseObject)
1018-
m.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", repo.GetPackFile)
1019-
m.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", repo.GetIdxFile)
1009+
m.Post("/git-upload-pack", CorsHandler(), repo.ServiceUploadPack)
1010+
m.Post("/git-receive-pack", CorsHandler(), repo.ServiceReceivePack)
1011+
m.Get("/info/refs", CorsHandler(), repo.GetInfoRefs)
1012+
m.Get("/HEAD", CorsHandler(), repo.GetTextFile("HEAD"))
1013+
m.Get("/objects/info/alternates", CorsHandler(), repo.GetTextFile("objects/info/alternates"))
1014+
m.Get("/objects/info/http-alternates", CorsHandler(), repo.GetTextFile("objects/info/http-alternates"))
1015+
m.Get("/objects/info/packs", CorsHandler(), repo.GetInfoPacks)
1016+
m.Get("/objects/info/{file:[^/]*}", CorsHandler(), repo.GetTextFile(""))
1017+
m.Get("/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", CorsHandler(), repo.GetLooseObject)
1018+
m.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.pack", CorsHandler(), repo.GetPackFile)
1019+
m.Get("/objects/pack/pack-{file:[0-9a-f]{40}}.idx", CorsHandler(), repo.GetIdxFile)
10201020
}, ignSignInAndCsrf)
10211021

10221022
m.Head("/tasks/trigger", repo.TriggerTask)

0 commit comments

Comments
 (0)