Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to fetch environment variables? #42

Open
noga-dev opened this issue May 19, 2023 · 2 comments
Open

How to fetch environment variables? #42

noga-dev opened this issue May 19, 2023 · 2 comments

Comments

@noga-dev
Copy link

noga-dev commented May 19, 2023

const testEnvVar = String.fromEnvironment(
    'SUPABASE_URL',
    defaultValue: 'defaultVal',
  );

The env var SUPABASE_URL comes built in as a default secret, per https://supabase.com/docs/guides/functions/secrets, yet defaultVal is returned.

@henry2man
Copy link

henry2man commented May 20, 2023

Secrets can be read using

Deno.env.get('VARIABLE_NAME')

Secrets must be managed by Supabase CLI with standard supabase secrets list/set commands. Secrets are written in environment files (DO NOT ADD THEM TO GIT, exclude them in .gitignore):

./supabase/.env (for PRODUCTION)
./supabase/.env.local (for local dev)

In order to make work local secrets during development, you need to add an extra --env-file file parameter to your serve command:

supabase functions serve dart_edge --no-verify-jwt --env-file ./supabase/.env.local

You can check this in the video https://youtu.be/53jhgrDONW4

Hope this helps

PS: Maybe we should add this to the README.md, isn't it?

@noga-dev
Copy link
Author

noga-dev commented May 20, 2023

Oh, I didn't realize I had access to Deno as an object inside main.dart. Thanks for this!

Works great and should definitely be added to the readme.

Leaving this issue open for the maintainers to address the docs/readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants