feat: support OAuth login on preview deployments - #63
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owner
Author
|
Intent: Let approved Vercel previews complete Google OAuth through the fixed production callback while using the existing production backend and client. |
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.
Problem / Motivation
Google accepts a fixed OAuth callback. Vercel preview URLs change for each deployment, so users cannot sign in to an authenticated preview.
Why it matters
Auth-gated changes cannot be tested in a real preview before they reach production.
What changed
Better Auth now accepts this Vercel project's preview hosts and uses its OAuth proxy plugin. Google still returns to the registered production callback. The backend encrypts the short-lived handoff and sends the user back to the preview, where Better Auth creates the session.
The preview uses the same Google client and production backend.
OAUTH_PROXY_SECRETis separate fromBETTER_AUTH_SECRET, and proxy payloads expire after 60 seconds. Origins outsideall-things-youtube-web-*.vercel.appremain blocked.flowchart LR subgraph Before P1[preview login]:::ctx --> G1[Google]:::removed --> X1[dynamic callback rejected]:::removed end subgraph After P2[preview login]:::ctx --> O[OAuth proxy]:::added --> G2[Google]:::ctx --> C[production callback]:::changed --> P3[preview session]:::added end classDef added fill:#DCFCE7,stroke:#16A34A,color:#14532D,stroke-width:2px classDef changed fill:#FEF3C7,stroke:#D97706,color:#78350F,stroke-width:2px classDef removed fill:#FEE2E2,stroke:#DC2626,color:#7F1D1D,stroke-dasharray:4 3 classDef ctx fill:#E0F2FE,stroke:#0284C7,color:#0C4A6E linkStyle 0,1 stroke:#DC2626,stroke-dasharray:4 3 linkStyle 2,3,4,5 stroke:#16A34A,stroke-width:2px🟩 added · 🟨 changed · 🟥 removed · 🟦 unchanged
The preview now returns through the fixed production callback and receives its own session.
Tests
npm --prefix platform run buildnpx vitest run test/auth-config.test.tsnpm --prefix platform run test:auth:integration -- test/auth-worker.integration.test.tsManual verification
Deploy this branch to Vercel and the Worker, then complete Google sign-in from the preview URL. The external Google round trip cannot run in the local test Worker.
Screenshots / video
Not applicable. This changes authentication routing without changing rendered UI.
Issue link
no linked issue: requested directly during development.