Repository navigation
fix(core): preserve string-shorthand endpoint URL when merging a partial config override - #13493
Open
HeroCode007 wants to merge 1 commit into
Open
HeroCode007 wants to merge 1 commit into
HeroCode007 wants to merge 1 commit into
Conversation
…ial config override `authorization`, `token`, and `userinfo` accept a string shorthand for just the endpoint URL (e.g. Spotify's default: "https://accounts.spotify.com/authorize?scope=user-read-email"). When a user overrides only part of that config — e.g. `authorization: { params: { scope } }`, without a new `url`, exactly as the docs for customizing a provider recommend — `merge()` sees a string default next to an object override, can't combine them, and silently discards the string default entirely. The base URL is lost, and the final authorization request falls back to a hardcoded placeholder domain instead of the real provider endpoint. Promote the string default to `{ url }` before merging, so both sides are objects and `merge()` combines them instead of discarding one. Verified end-to-end with parseProviders() + Spotify's real default config: before this change the resulting authorization URL was "https://authjs.dev/?scope=...", after it's "https://accounts.spotify.com/authorize?scope=...". Fixes: nextauthjs#9448 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Someone is attempting to deploy a commit to the authjs Team on Vercel. A member of the Team first needs to authorize it. |
This branch was successfully deployed
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.
☕️ Reasoning
authorization,token, anduserinfoaccept a string shorthand for just the endpoint URL (e.g. Spotify's default:"https://accounts.spotify.com/authorize?scope=user-read-email"). When a user overrides only part of that config — e.g.authorization: { params: { scope } }, without a newurl, exactly as the docs for customizing a built-in OAuth provider recommend —merge()sees a string default next to an object override and can't combine them, so it silently resets the target to{}and discards the string default entirely. The base URL is lost, andnormalizeEndpointfalls back to its hardcoded placeholder (https://authjs.dev) instead of the real provider endpoint.This is the scenario originally reported in #9448 (Discord provider, scope override). A related direction of this bug (object default overridden by a string) was fixed in #11685, but that fix doesn't cover this case — I confirmed it's still reproducible today, straight from
main:Fix
Rather than changing
merge()itself (which is a generic deep-merge utility with no URL-specific knowledge), this promotes a string-shorthand default to{ url }before merging, inparseProviders, which already owns the domain knowledge thatauthorization/token/userinfosupport this shorthand. Both sides of the merge are then objects, somerge()combines them correctly instead of discarding one.After the fix, the same scenario produces:
Verified this doesn't affect the two existing merge-direction cases already covered in
merge.test.ts(string target fully replaced by an object override that includes its ownurl, and object target replaced by a string override).🧢 Checklist
🎫 Affected issues
Fixes: #9448