feat(config): support env() references in auth hook URI fields #4641
+14
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enables
env()variable references in auth hook URI fields, solving the configuration problem for preview branches where the project URL is dynamic.Problem
When using Supabase branching, each preview branch gets a unique URL (e.g.,
https://<random-id>.supabase.co). Users configuring HTTP auth hooks face a problem:http://host.docker.internal:54321/functions/v1/send_emailhttps://myproject.supabase.co/functions/v1/send-emailhttps://<dynamic-id>.supabase.co/functions/v1/send-emailThe
secretsfield supportsenv()references, buturidid not. When users tried:The CLI rejected it because validation tried to parse the unresolved string as a URL and failed on the scheme check.
Solution
Skip URI validation when the field contains an
env()reference, allowing the platform to resolve it at deploy time. This follows the same pattern used for other config fields (likeauth.site_url,auth.external.*.redirect_uri, etc.) which already supportenv()references.Changes
pkg/config/config.go: Added check inhookConfig.validate()to skip validation when URI containsenv(pattern, with a warning messagepkg/config/config_test.go: Added test case forenv()URI referencesUsage
Users can now write:
And set the environment variable appropriately per environment:
.envcan usehost.docker.internalTesting
All existing tests pass, plus new test case:
URI_with_env()_reference_skips_validation✅Future Considerations
For a more seamless experience, the platform could automatically inject a
SUPABASE_PROJECT_URLenvironment variable when deploying preview branches. This would pair well with this CLI change to provide zero-config preview branch support for auth hooks.Related Issues
cc @kallebysantos