diff options
author | Unknwon <u@gogs.io> | 2017-01-28 19:59:17 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-01-28 19:59:17 -0500 |
commit | 5e01ecbc0528488427ee455578acbe7ff92efcfe (patch) | |
tree | 5a1ec8467ce931e04a28bb079dd24e8180512b6f /modules/context/context.go | |
parent | c98aa0e8950393ac43dc66e8de85973d9cd029ef (diff) |
Able to set custom Access-Control-Allow-Origin header (#3987)
Added new config option '[http] ACCESS_CONTROL_ALLOW_ORIGIN'.
Diffstat (limited to 'modules/context/context.go')
-rw-r--r-- | modules/context/context.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/context/context.go b/modules/context/context.go index ac46bb38..228ed3d8 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -156,6 +156,11 @@ func Contexter() macaron.Handler { }, Org: &Organization{}, } + + if len(setting.HTTP.AccessControlAllowOrigin) > 0 { + ctx.Header().Set("Access-Control-Allow-Origin", setting.HTTP.AccessControlAllowOrigin) + } + // Compute current URL for real-time change language. ctx.Data["Link"] = setting.AppSubUrl + strings.TrimSuffix(ctx.Req.URL.Path, "/") |