From 9fb7eec04b3fdada0e51ec5595174950d1e43a43 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Thu, 16 Nov 2017 20:46:54 +0000 Subject: [PATCH] Add specific HTTP CORS headers --- web/web.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/web/web.go b/web/web.go index af831813..afbe3970 100644 --- a/web/web.go +++ b/web/web.go @@ -45,7 +45,6 @@ func Setup(opts *cnf.Options) (err error) { s.Use(mw.Logs()) // Log requests s.Use(mw.Sock()) // Log requests s.Use(mw.Gzip()) // Gzip responses - s.Use(mw.Cors()) // Add cors headers // Add trace information @@ -55,6 +54,30 @@ func Setup(opts *cnf.Options) (err error) { s.Use(auth()) + // Add cors headers + + s.Use(mw.Cors(&mw.CorsOpts{ + AllowedOrigin: "*", + AllowedMethods: []string{ + "GET", + "PUT", + "POST", + "PATCH", + "DELETE", + "TRACE", + "OPTIONS", + }, + AllowedHeaders: []string{ + "Accept", + "Authorization", + "Content-Type", + "Origin", + "NS", + "DB", + }, + AccessControlMaxAge: 600, + })) + // Check body size s.Use(mw.Size(&mw.SizeOpts{