From b9bb4a62d60c0e8b863f160e5f35e67b94c18e6c Mon Sep 17 00:00:00 2001 From: Girish Sonawane Date: Sat, 11 Mar 2017 13:31:59 +0530 Subject: api: make CORS work by handling preflight OPTIONS request (#4264) * make CORS work by handling preflight OPTIONS request * Update api.go --- modules/context/context.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules') diff --git a/modules/context/context.go b/modules/context/context.go index e3cc6f6b..31378532 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -159,6 +159,9 @@ func Contexter() macaron.Handler { if len(setting.HTTP.AccessControlAllowOrigin) > 0 { ctx.Header().Set("Access-Control-Allow-Origin", setting.HTTP.AccessControlAllowOrigin) + ctx.Header().Set("'Access-Control-Allow-Credentials' ", "true") + ctx.Header().Set("Access-Control-Max-Age", "3600") + ctx.Header().Set("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With") } // Compute current URL for real-time change language. -- cgit v1.2.3