Add config options for cors handling (#124)
Add config options for cors handling Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/124
This commit is contained in:
@ -94,6 +94,10 @@ const (
|
||||
MigrationWunderlistClientID Key = `migration.wunderlist.clientid`
|
||||
MigrationWunderlistClientSecret Key = `migration.wunderlist.clientsecret`
|
||||
MigrationWunderlistRedirectURL Key = `migration.wunderlist.redirecturl`
|
||||
|
||||
CorsEnable Key = `cors.enable`
|
||||
CorsOrigins Key = `cors.origins`
|
||||
CorsMaxAge Key = `cors.maxage`
|
||||
)
|
||||
|
||||
// GetString returns a string config value
|
||||
@ -121,6 +125,11 @@ func (k Key) GetDuration() time.Duration {
|
||||
return viper.GetDuration(string(k))
|
||||
}
|
||||
|
||||
// GetStringSlice returns a string slice from a config option
|
||||
func (k Key) GetStringSlice() []string {
|
||||
return viper.GetStringSlice(string(k))
|
||||
}
|
||||
|
||||
// Set sets a value
|
||||
func (k Key) Set(i interface{}) {
|
||||
viper.Set(string(k), i)
|
||||
@ -205,6 +214,10 @@ func InitDefaultConfig() {
|
||||
// Files
|
||||
FilesBasePath.setDefault("files")
|
||||
FilesMaxSize.setDefault("20MB")
|
||||
// Cors
|
||||
CorsEnable.setDefault(true)
|
||||
CorsOrigins.setDefault([]string{"*"})
|
||||
CorsMaxAge.setDefault(0)
|
||||
}
|
||||
|
||||
// InitConfig initializes the config, sets defaults etc.
|
||||
|
Reference in New Issue
Block a user