-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Description
I like the concept of preview branches - thank you to the team for implementing it. However, I’ve run into an issue with the send email hook configuration when using it with an Edge Function.
Steps
I created an Edge Function and then added it to the config.
Local env
For local development, I need to use host.docker.internal, so my local configuration looks like this:
[auth.hook.send_email]
enabled = true
uri = "http://host.docker.internal:54321/functions/v1/send_email"
secrets = "env(SEND_EMAIL_HOOK_SECRETS)"Production
But when deploying, I get an error that the URI must use https or pg-functions.... So for production I changed the URL to such pattern:
[auth.hook.send_email]
uri = "https://aaaaaaaaaaaaaa.supabase.co/functions/v1/send-email"Preview enviroment
However, this URL obviously doesn’t work for preview environments, since each preview branch gets its own URL. That means I have to manually update the URI in the preview branch dashboard after every commit.
Solutions that I tried
I think it might be possible to fix this by using [remote.<branch>] to override the URI for each persistent branch, but for each preview branch I would need to create a new entry in the config and then delete it before merging. So this approach doesn’t really work.
I also tried to set the value using environment variables like this:
[auth.hook.send_email]
uri = "env(SUPABASE_URL)/functions/v1/send-email"But this has two issues:
- Such config doesn’t pass validation during deployment. I get the same error, like at the begining, that the URI should start with
httpsorpg-functions.... The only way to pass validation is to write it like this:
uri = "https://env(SUPABASE_URL)/functions/v1/send-email", which results in an incorrect final URL. - Even if the config passes validation, the environment variable still isn’t resolved, so the hook URI ends up literally as
"https://env(SUPABASE_URL)/functions/v1/send-email"
I haven’t found any solution in the documentation, so I’m wondering whether there are plans to add something like [remote.preview] or a enviroment variables templating solution, similar to how YAML configs work in GitHub Actions.
Originally posted by @LeoVS09 in #18937 (comment)