netlify / gotrue

An SWT based API for managing users and issuing SWT tokens.
https://www.gotrueapi.org
MIT License
3.82k stars 283 forks source link

environment variables do not override file-based configuration #289

Closed tmbrwn closed 2 years ago

tmbrwn commented 3 years ago

Bug: environment variables are overridden by file-based configuration

Current Behavior

GoTrue will ignore any parameters passed in through the environment if the same parameter is specified in a .env file as well. This is contrary to the documentation, which states that environment variables take precedence over file-based configuration.

The issue appears to be due to https://github.com/gobuffalo/envy/issues/36. Envy is a dependency of github.com/gobuffalo/pop, which is a dependency of this project.

Workarounds

The issue with envy applies to any parameters specified in a file called .env. If no such file exists, and any configuration is done with another file and referenced with gotrue -c some-other-config-file, then configuration will function as intended.

Steps to Reproduce

.env

GOTRUE_SITE_URL=someurl.com
GOTRUE_DISABLE_SIGNUP=false
GOTRUE_OPERATOR_TOKEN=bogustoken

GOTRUE_API_HOST=0.0.0.0
GOTRUE_API_PORT=8082

GOTRUE_DB_DRIVER=mysql
GOTRUE_DB_DATABASE_URL=root@tcp(localhost:3306)/gotrue_development?multiStatements=true&parseTime=true

GOTRUE_JWT_SECRET=itsnosecret
GOTRUE_JWT_EXP=3600

(the content of the .env is not too important but this is an example with all required parameters set)

Invocation: GOTRUE_DB_DATABASE_URL=root@tcp(someotherhost:3306)/gotrue_development?multiStatements=true&parseTime=true ./gotrue

Result: GoTrue attempts to reach the database at localhost:3306 rather than someotherhost:3306. (built using go1.16.3 darwin/amd64)

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 7 days if no further activity occurs. Thanks!

github-actions[bot] commented 2 years ago

This issue was closed because it had no activity for over 1 year.