aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hilton <wmhilton@gmail.com>2018-11-07 18:14:15 -0500
committer无闻 <u@gogs.io>2018-11-07 18:14:15 -0500
commitdae311ea9d654b1510a64fd5a2d21e25c2b65529 (patch)
treeb3af5cb68e3eab47aaa001b76d7c139839a6468f
parent4677b469044bc23e98b4cd265495dbffb9be335a (diff)
repo/http: update CORS headers to allow custom user-agent (#5498)
At some point after #4970 was merged, isomorphic-git started sending a custom User-Agent in its HTTP requests to deal with some services (\*cough\* gists \*cough\*) which filtered git traffic by User-Agent. Sadly, this broke cloning from Gogs using isomorphic-git in the browser (https://github.com/isomorphic-git/isomorphic-git/issues/555). This PR fixes it by telling browsers it is OK for CORS requests to send a custom User-Agent header.
-rw-r--r--routes/repo/http.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/routes/repo/http.go b/routes/repo/http.go
index 3ec7628e..9f0f311b 100644
--- a/routes/repo/http.go
+++ b/routes/repo/http.go
@@ -47,7 +47,7 @@ func HTTPContexter() macaron.Handler {
if len(setting.HTTP.AccessControlAllowOrigin) > 0 {
// Set CORS headers for browser-based git clients
c.Resp.Header().Set("Access-Control-Allow-Origin", setting.HTTP.AccessControlAllowOrigin)
- c.Resp.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
+ c.Resp.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, User-Agent")
// Handle preflight OPTIONS request
if c.Req.Method == "OPTIONS" {