refactor: enable cors - dev env + swagger is disabled by default
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Dawid Wysokiński 2022-11-26 08:14:56 +01:00
parent 786cc60e38
commit 10cb5b83b1
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
4 changed files with 33 additions and 3 deletions

View File

@ -130,13 +130,13 @@ func newServer(cfg serverConfig) (*http.Server, error) {
}
type apiConfig struct {
SwaggerEnabled bool `envconfig:"SWAGGER_ENABLED" default:"true"`
SwaggerEnabled bool `envconfig:"SWAGGER_ENABLED" default:"false"`
SwaggerHost string `envconfig:"SWAGGER_HOST" default:""`
SwaggerSchemes []string `envconfig:"SWAGGER_SCHEMES" default:"http,https"`
CORSEnabled bool `envconfig:"CORS_ENABLED" default:"false"`
CORSAllowedOrigins []string `envconfig:"CORS_ALLOWED_ORIGINS" default:""`
CORSAllowCredentials bool `envconfig:"CORS_ALLOW_CREDENTIALS" default:"false"`
CORSAllowedMethods []string `envconfig:"CORS_ALLOWED_METHODS" default:"HEAD,GET"`
CORSAllowedMethods []string `envconfig:"CORS_ALLOWED_METHODS" default:"HEAD,GET,POST,PUT"`
CORSMaxAge uint32 `envconfig:"CORS_MAX_AGE" default:"300"`
}

View File

@ -31,7 +31,7 @@ spec:
- name: DB_MAX_IDLE_CONNECTIONS
value: "5"
- name: API_SWAGGER_ENABLED
value: "true"
value: "false"
livenessProbe:
httpGet:
path: /_meta/livez

28
k8s/overlays/dev/api.yml Normal file
View File

@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: sessions-api-deployment
spec:
template:
spec:
containers:
- name: sessions-api
image: sessions
env:
- name: APP_MODE
value: development
- name: DB_DSN
valueFrom:
secretKeyRef:
name: sessions-secret
key: db-dsn
- name: DB_MAX_OPEN_CONNECTIONS
value: "10"
- name: DB_MAX_IDLE_CONNECTIONS
value: "5"
- name: API_SWAGGER_ENABLED
value: "true"
- name: API_CORS_ENABLED
value: "true"
- name: API_CORS_ALLOWED_ORIGINS
value: "*"

View File

@ -4,3 +4,5 @@ nameSuffix: -dev
resources:
- secret.yml
- ../../base
patchesStrategicMerge:
- api.yml