fix: preserve API_EXTERNAL_URL path when building confirmation links#2591
Open
tsushanth wants to merge 1 commit into
Open
fix: preserve API_EXTERNAL_URL path when building confirmation links#2591tsushanth wants to merge 1 commit into
tsushanth wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2518
When
API_EXTERNAL_URLincludes a path prefix (e.g.http://127.0.0.1:54321/auth/v1), Go'surl.ResolveReferenceimplements RFC 3986 §5.2 and replaces the entire base path with the reference path. Every confirmation and magic-link URL built intemplatemailer.gousesexternalURL.ResolveReference(path), so the/auth/v1prefix is silently dropped and the link 404s.The fix introduces
resolveWithBasePath, a thin wrapper that prepends the base URL's path to the reference path rather than replacing it, then replaces all six call sites. The behavior is unchanged whenAPI_EXTERNAL_URLhas no path (the common case), becausestrings.TrimRight("", "/")is"".Affected call sites:
InviteMail,ConfirmationMail,EmailChangeMail,RecoveryMail,MagicLinkMail,GetEmailActionLink.The existing URL test fixture is updated to reflect the correct (non-buggy) expectation, and a new case covering the Supabase CLI default (
/auth/v1base path) is added.