Allows browser extensions in cors (#317)

This commit is contained in:
Stewart Thomson 2020-05-10 02:32:27 -04:00 committed by GitHub
parent 7523ad0d2e
commit 93b30c5c44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View File

@ -14,6 +14,7 @@ import (
func CorsConfig(conf *config.Configuration) cors.Config { func CorsConfig(conf *config.Configuration) cors.Config {
corsConf := cors.Config{ corsConf := cors.Config{
MaxAge: 12 * time.Hour, MaxAge: 12 * time.Hour,
AllowBrowserExtensions: true,
} }
if mode.IsDev() { if mode.IsDev() {
corsConf.AllowAllOrigins = true corsConf.AllowAllOrigins = true

View File

@ -26,6 +26,7 @@ func TestCorsConfig(t *testing.T) {
AllowHeaders: []string{"content-type"}, AllowHeaders: []string{"content-type"},
AllowMethods: []string{"GET"}, AllowMethods: []string{"GET"},
MaxAge: 12 * time.Hour, MaxAge: 12 * time.Hour,
AllowBrowserExtensions: true,
}, actual) }, actual)
assert.NotNil(t, allowF) assert.NotNil(t, allowF)
assert.True(t, allowF("http://test.com")) assert.True(t, allowF("http://test.com"))
@ -45,6 +46,7 @@ func TestEmptyCorsConfigWithResponseHeaders(t *testing.T) {
AllowAllOrigins: false, AllowAllOrigins: false,
AllowOrigins: []string{"https://example.com"}, AllowOrigins: []string{"https://example.com"},
MaxAge: 12 * time.Hour, MaxAge: 12 * time.Hour,
AllowBrowserExtensions: true,
}, actual) }, actual)
} }
@ -63,5 +65,6 @@ func TestDevCorsConfig(t *testing.T) {
AllowMethods: []string{"GET", "POST", "DELETE", "OPTIONS", "PUT"}, AllowMethods: []string{"GET", "POST", "DELETE", "OPTIONS", "PUT"},
MaxAge: 12 * time.Hour, MaxAge: 12 * time.Hour,
AllowAllOrigins: true, AllowAllOrigins: true,
AllowBrowserExtensions: true,
}, actual) }, actual)
} }