Allow more CORS configuration customization

This commit is contained in:
wpetit 2020-06-22 10:07:35 +02:00
parent 788f0459fb
commit 12d51559bf
2 changed files with 4 additions and 0 deletions

View File

@ -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"`

View File

@ -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,
})