Allow more CORS configuration customization
This commit is contained in:
parent
788f0459fb
commit
12d51559bf
|
@ -46,6 +46,8 @@ type Serv struct {
|
||||||
SeedFile string `mapstructure:"seed_file"`
|
SeedFile string `mapstructure:"seed_file"`
|
||||||
MigrationsPath string `mapstructure:"migrations_path"`
|
MigrationsPath string `mapstructure:"migrations_path"`
|
||||||
AllowedOrigins []string `mapstructure:"cors_allowed_origins"`
|
AllowedOrigins []string `mapstructure:"cors_allowed_origins"`
|
||||||
|
AllowedMethods []string `mapstructure:"cors_allowed_methods"`
|
||||||
|
AllowedHeaders []string `mapstructure:"cors_allowed_headers"`
|
||||||
DebugCORS bool `mapstructure:"cors_debug"`
|
DebugCORS bool `mapstructure:"cors_debug"`
|
||||||
APIPath string `mapstructure:"api_path"`
|
APIPath string `mapstructure:"api_path"`
|
||||||
CacheControl string `mapstructure:"cache_control"`
|
CacheControl string `mapstructure:"cache_control"`
|
||||||
|
|
|
@ -43,6 +43,8 @@ func apiV1Handler() http.Handler {
|
||||||
if len(conf.AllowedOrigins) != 0 {
|
if len(conf.AllowedOrigins) != 0 {
|
||||||
c := cors.New(cors.Options{
|
c := cors.New(cors.Options{
|
||||||
AllowedOrigins: conf.AllowedOrigins,
|
AllowedOrigins: conf.AllowedOrigins,
|
||||||
|
AllowedHeaders: conf.AllowedHeaders,
|
||||||
|
AllowedMethods: conf.AllowedMethods,
|
||||||
AllowCredentials: true,
|
AllowCredentials: true,
|
||||||
Debug: conf.DebugCORS,
|
Debug: conf.DebugCORS,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue