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.
pull/5508/head
William Hilton 2018-11-07 18:14:15 -05:00 committed by 无闻
parent 4677b46904
commit dae311ea9d
1 changed files with 1 additions and 1 deletions

View File

@ -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" {