feat: supabase public url #4604
Open
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.
What kind of change does this PR introduce?
Feature - Enables local development and testing of OAuth-protected Edge Functions (like MCP servers).
What is the current behavior?
When building OAuth-protected Edge Functions locally, there are two issues:
No OAuth Protected Resource discovery: There's no way for OAuth clients to discover the authorization server for a protected Edge Function resource via the standard
/.well-known/oauth-protected-resourcepath.Internal Docker URLs exposed:
SUPABASE_URLis set tohttp://kong:8000(internal Docker network), which external OAuth clients cannot resolve. This breaks OAuth metadata responses that need client-facing URLs.What is the new behavior?
1. OAuth Protected Resource Metadata Endpoint
Added Kong route that redirects:
This enables OAuth clients to discover the authorization server for any Edge Function per RFC 9728.
2.
SUPABASE_PUBLIC_URLEnvironment VariableAdded a new environment variable passed to Edge Functions containing the external-facing URL (e.g.,
http://127.0.0.1:54321).Edge Functions can use:
SUPABASE_URL→ for internal API calls (server-to-server within Docker)SUPABASE_PUBLIC_URL→ for client-facing URLs (OAuth metadata, redirects)Example usage:
Production compatibility: In production,
SUPABASE_PUBLIC_URLwon't exist, so Edge Functions fall back toSUPABASE_URL(which is already the public URL).Closes https://linear.app/supabase/issue/DEVWF-940/add-supabase-public-url-environment-variable-to-edge-functions
Related issue: https://linear.app/supabase/issue/AI-311/add-oauth-authentication-section-to-byom-one-pager-docs