cli
cli copied to clipboard
Allow reading config values from .env file
Feature request
Hello, I tried looking through the docs for a way to set secret values in config.toml
by reading a .env
file, but I couldn't find anything.
Searching the issues I found this one #210 which seems related to what I am asking for, but I couldn't understand how to get things working.
I tried doing this in my config.toml
file:
[auth.external.github]
client_id = "env(GITHUB_CLIENT_ID)"
enabled = true
secret = "env(GITHUB_SECRET)"
and I created a .env
file:
export GITHUB_CLIENT_ID=...
export GITHUB_SECRET=...
and finally started supabase by running this command:
(source .env && supabase start)
Which doesn't seem to work, trying to log in using github causes supabase to create a url that looks like this:
https://github.com/login/oauth/authorize?client_id=env%28GITHUB_CLIENT_ID%29
So it seems to copy the value stored in config.toml
literally.
Any help is appreciated, thanks!
since config.toml is commited to my repository I don't want to expose the google client id and secret.
would be nice if we could reference env vars from .env.development or similar for example.
Here is what I am doing to make it work, I think it should work with github too.
- Created .env file in supabase directory with following content
export GOOGLE_CLIENT_ID="google client id"
export GOOGLE_SECRET="google secret"
- config.toml
[auth.external.google]
enabled = true
client_id = "env(GOOGLE_CLIENT_ID)"
secret = "env(GOOGLE_SECRET)"
- run
source ./supabase/.env && supabase start
in root of the project
Thanks all, seems like this issue is the same as https://github.com/supabase/cli/issues/210#issuecomment-1201213636, which should be fixed by now.
Hi, I use windows and source
isn't available in the cmd / powershell.
The workaround I found is to use env-cmd - sharing in case someone encounters the same issue. Also happy to hear if there is any better solution.
UPDATE: It turns out this does work on Windows, just make sure you are using the latest version with either npx
or scoop
.
To be clear for windows users:
npm i -D env-cmd
then
npx env-cmd npx supabase start
J
I created a feature request for the --env-file
flag so that it will work for everyone (Unix and Windows) and we can select .env
file we want in local development.
J
@isaif 's proposal seems to work on mac, but my .env files do not normally need export
so I feel there should be a better solution to support .env
files