From 5e01ecbc0528488427ee455578acbe7ff92efcfe Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 28 Jan 2017 19:59:17 -0500 Subject: Able to set custom Access-Control-Allow-Origin header (#3987) Added new config option '[http] ACCESS_CONTROL_ALLOW_ORIGIN'. --- modules/context/context.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/context') 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, "/") -- cgit v1.2.3