-
Notifications
You must be signed in to change notification settings - Fork 319
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
When running Supabase locally, environment variables used in the config.toml file (for example, inside auth.hook.custom_access_token.secret) are not loaded from the same .env file used by Edge Functions.
Currently, Edge Functions correctly load variables from supabase/functions/.env, but config.toml only reads variables from the project root .env.
As a result, the same variable (e.g. CUSTOM_ACCESS_TOKEN_SECRET) must be duplicated in both places for the setup to work — which is error-prone and confusing.
Ideally, both environments (Supabase services and Edge Functions) should share the same .env context, or config.toml should also look for environment variables inside supabase/functions/.env when running locally.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Define the variable only in
supabase/functions/.env:CUSTOM_ACCESS_TOKEN_SECRET=super_secret_value
- Reference it in
supabase/config.toml:[auth.hook.custom_access_token] secret = "env(CUSTOM_ACCESS_TOKEN_SECRET)"
- Run:
supabase start
- Observe that Supabase fails to validate the JWT hook with:
Invalid hook config: auth.hook.custom_access_token.secrets must be formatted as "v1,whsec_<base64_encoded_secret>" - Duplicating the variable in the root
.envfile fixes the issue.
Expected behavior
config.toml should also read environment variables from the same .env file used by Edge Functions (supabase/functions/.env) to avoid duplication and inconsistencies.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- OS: MacOS
- Version of supabase-js: 2.80.0
- Version of Node.js: 22.17.0
Additional context
This issue becomes noticeable when using custom JWT hooks or other configurations that rely on secrets defined for local development.
Allowing config.toml to access variables from supabase/functions/.env, or providing a clear hierarchy for env loading (root → functions), would greatly improve DX and reduce confusion.