From 12d51559bf9daf75b002b7c2bff3dae9e14dbd56 Mon Sep 17 00:00:00 2001 From: William Petit Date: Mon, 22 Jun 2020 10:07:35 +0200 Subject: [PATCH] Allow more CORS configuration customization --- internal/serv/api.go | 2 ++ internal/serv/http.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/internal/serv/api.go b/internal/serv/api.go index 1ef7538..cf32d52 100644 --- a/internal/serv/api.go +++ b/internal/serv/api.go @@ -46,6 +46,8 @@ type Serv struct { SeedFile string `mapstructure:"seed_file"` MigrationsPath string `mapstructure:"migrations_path"` AllowedOrigins []string `mapstructure:"cors_allowed_origins"` + AllowedMethods []string `mapstructure:"cors_allowed_methods"` + AllowedHeaders []string `mapstructure:"cors_allowed_headers"` DebugCORS bool `mapstructure:"cors_debug"` APIPath string `mapstructure:"api_path"` CacheControl string `mapstructure:"cache_control"` diff --git a/internal/serv/http.go b/internal/serv/http.go index f1d513c..339986c 100644 --- a/internal/serv/http.go +++ b/internal/serv/http.go @@ -43,6 +43,8 @@ func apiV1Handler() http.Handler { if len(conf.AllowedOrigins) != 0 { c := cors.New(cors.Options{ AllowedOrigins: conf.AllowedOrigins, + AllowedHeaders: conf.AllowedHeaders, + AllowedMethods: conf.AllowedMethods, AllowCredentials: true, Debug: conf.DebugCORS, })