diff options
author | Elias Nahum <nahumhbl@gmail.com> | 2016-03-01 13:00:54 -0300 |
---|---|---|
committer | Elias Nahum <nahumhbl@gmail.com> | 2016-03-01 13:00:54 -0300 |
commit | ba6a38a7f6c497e025708111046d67875c4361be (patch) | |
tree | 7db65506f395a8d98de086d2b184b33b47f8b2fc /api | |
parent | 8aa4e28932ec43090ca6b481929fafbe0119a660 (diff) | |
download | chat-ba6a38a7f6c497e025708111046d67875c4361be.tar.gz chat-ba6a38a7f6c497e025708111046d67875c4361be.tar.bz2 chat-ba6a38a7f6c497e025708111046d67875c4361be.zip |
Allow CORS
Diffstat (limited to 'api')
-rw-r--r-- | api/context.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/api/context.go b/api/context.go index 9e05c5d87..3b9782851 100644 --- a/api/context.go +++ b/api/context.go @@ -166,6 +166,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // All api response bodies will be JSON formatted by default w.Header().Set("Content-Type", "application/json") + if len(utils.Cfg.ServiceSettings.AllowCorsFrom) > 0 { + w.Header().Set("Access-Control-Allow-Origin", utils.Cfg.ServiceSettings.AllowCorsFrom) + } + if r.Method == "GET" { w.Header().Set("Expires", "0") } |