[PR #6421] [MERGED] feat(client): add fallback support for VERCEL_URL and NEXTAUTH_URL #23556

Closed
opened 2026-04-15 21:49:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6421
Author: @GautamBytes
Created: 11/30/2025
Status: Merged
Merged: 3/1/2026
Merged by: @Bekacru

Base: canaryHead: feat/vercel-url-fallback


📝 Commits (3)

  • d1b627b feat(client): add fallback support for VERCEL_URL and NEXTAUTH_URL
  • ec94d70 fix: ensure fallback URLs include auth base path
  • 8a3b345 fix: use nullish coalescing for basePath to support empty strings

📊 Changes

1 file changed (+29 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/client/config.ts (+29 -0)

📄 Description

Description

This PR adds automatic baseURL resolution for Vercel deployments and improves compatibility with NextAuth.js environment variables.

Currently, users deploying to Vercel often need to manually configure NEXT_PUBLIC_AUTH_URL. This change allows the client configuration to automatically fall back to VERCEL_URL or NEXTAUTH_URL if the explicit baseURL or NEXT_PUBLIC_AUTH_URL are missing.

Closes #6406


Summary by cubic

Automatically resolves the client baseURL for Vercel deployments by falling back to VERCEL_URL or NEXTAUTH_URL when baseURL or NEXT_PUBLIC_AUTH_URL are not set. This reduces manual config and improves NextAuth compatibility.

  • New Features
    • Adds resolvePublicAuthUrl to infer the public auth URL from env vars.
    • Order: NEXT_PUBLIC_AUTH_URL → (server-side) NEXTAUTH_URL → VERCEL_URL (defaults to https), with the auth base path appended for VERCEL_URL.
    • If none are set, falls back to /api/auth.

Written for commit 8a3b34594b. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6421 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 11/30/2025 **Status:** ✅ Merged **Merged:** 3/1/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `feat/vercel-url-fallback` --- ### 📝 Commits (3) - [`d1b627b`](https://github.com/better-auth/better-auth/commit/d1b627b577fdddecfd93eed021338ec1948b1e92) feat(client): add fallback support for VERCEL_URL and NEXTAUTH_URL - [`ec94d70`](https://github.com/better-auth/better-auth/commit/ec94d70ed041d47d6b626e5e0851d8703199d16e) fix: ensure fallback URLs include auth base path - [`8a3b345`](https://github.com/better-auth/better-auth/commit/8a3b34594bc3f7dd655a78c10f86a2fe325311d0) fix: use nullish coalescing for basePath to support empty strings ### 📊 Changes **1 file changed** (+29 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/config.ts` (+29 -0) </details> ### 📄 Description ## Description This PR adds automatic `baseURL` resolution for Vercel deployments and improves compatibility with NextAuth.js environment variables. Currently, users deploying to Vercel often need to manually configure `NEXT_PUBLIC_AUTH_URL`. This change allows the client configuration to automatically fall back to `VERCEL_URL` or `NEXTAUTH_URL` if the explicit `baseURL` or `NEXT_PUBLIC_AUTH_URL` are missing. ## Related Issue Closes #6406 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Automatically resolves the client baseURL for Vercel deployments by falling back to VERCEL_URL or NEXTAUTH_URL when baseURL or NEXT_PUBLIC_AUTH_URL are not set. This reduces manual config and improves NextAuth compatibility. - **New Features** - Adds resolvePublicAuthUrl to infer the public auth URL from env vars. - Order: NEXT_PUBLIC_AUTH_URL → (server-side) NEXTAUTH_URL → VERCEL_URL (defaults to https), with the auth base path appended for VERCEL_URL. - If none are set, falls back to /api/auth. <sup>Written for commit 8a3b34594bc3f7dd655a78c10f86a2fe325311d0. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 21:49:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#23556