cli icon indicating copy to clipboard operation
cli copied to clipboard

Support boolean in Config.toml env substitution

Open goszczynskip opened this issue 1 year ago • 4 comments

Describe the bug env isn't working for some config.toml keys for example enabled = env(MY_VAR) in auth section.

To Reproduce Steps to reproduce the behavior:

  1. Add following Google OAuth config in config.toml file
[auth.external.google]
enabled = env(GOOGLE_OAUTH_ENABLED)
client_id = "env(GOOGLE_CLIENT_ID)"
secret = "env(GOOGLE_SECRET)"
  1. Add .env file in the project root with envs
GOOGLE_OAUTH_ENABLED=false
  1. Try to start supabase via supabase start command
  2. See error
cannot read config in /[redacted]: toml: line 64 (last key "auth.external.google.enabled"): expected value but found "env" instead

Expected behavior I can start the project with auth enabled or disabled based on the env value.

Desktop (please complete the following information):

  • OS: macOS
  • Version of CLI v1.77.9
  • Version of Node.js (if applicable) v18.14.0

goszczynskip avatar Jul 21 '23 11:07 goszczynskip

@sweatybridge any progress on this issue? Error evaluating "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID)": environment variable SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID is unset.

G9000 avatar Dec 14 '23 09:12 G9000

@G9000 that looks like a config error. env(SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID) is present in your config.toml but the env var is undefined. Did you forget to define the env var?

sweatybridge avatar Dec 14 '23 13:12 sweatybridge

@G9000 that looks like a config error. env(SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID) is present in your config.toml but the env var is undefined. Did you forget to define the env var?

I did, it seems not detecting at all. I saw this thread but not working for me.

G9000 avatar Dec 14 '23 13:12 G9000

secret = "SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET"

That's just a static value and not using substitution.

You want to keep secret = "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET)" in config.toml and try the following

SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=abc supabase start

Or

echo "SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=abc" > .env
supabase start

Or

export SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=abc
supabase start

They all should load the env var correctly into your config.toml at runtime.

sweatybridge avatar Dec 14 '23 13:12 sweatybridge