Skip to content

fix(auth): resolve deduplicated OAuth callback redirects against base URL - #3329

Open
krzeznicki wants to merge 1 commit into
elie222:mainfrom
krzeznicki:fix/self-hosted-oauth-callback-dedup-redirect
Open

fix(auth): resolve deduplicated OAuth callback redirects against base URL#3329
krzeznicki wants to merge 1 commit into
elie222:mainfrom
krzeznicki:fix/self-hosted-oauth-callback-dedup-redirect

Conversation

@krzeznicki

@krzeznicki krzeznicki commented Aug 17, 2026

Copy link
Copy Markdown

Fixes #3326

On self-hosted standalone deployments, request.url carries the server's internal origin (e.g. the Docker container hostname), so the deduplicated OAuth callback response redirected users to https://<container-id>:3000/welcome-redirect (ERR_NAME_NOT_RESOLVED). better-auth returns a relative Location, which only breaks when the cached (second) response absolutizes it against request.url.

  • resolve cached redirects and the welcome-path fallbacks against env.NEXT_PUBLIC_BASE_URL instead of request.url
  • drop the now-unused request param from createCachedRedirect
  • add regression tests: a relative cached redirect and the wait-timeout path, both with an internal-origin request URL

Validation: pnpm test utils/oauth/auth-callback-deduplication.test.ts — 11 passed; the two new tests reproduced the container-origin redirect before the fix. No behavior change on Vercel, where request.url and NEXT_PUBLIC_BASE_URL share the same origin.

Review in cubic

@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown

@krzeznicki is attempting to deploy a commit to the Inbox Zero OSS Program Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Aug 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Self-hosted: deduplicated OAuth callback redirects to container-internal origin (https://<container-id>:3000)

2 participants