Auth.js · browser URL

Redirected to localhost after deploy

what it looks like
https://your-app.com → sign in → http://localhost:3000/api/auth/callback/github

What it means

If AUTH_URL or NEXTAUTH_URL is set, next-auth v5 rewrites the request's origin to it. A localhost value copied into production sends every user back to localhost.

Common causes

  • NEXTAUTH_URL=http://localhost:3000 copied from a v4 tutorial into the host's env vars
  • AUTH_URL left over from local testing

How to fix it

  1. Delete AUTH_URL and NEXTAUTH_URL from production. v5 infers the host from the request
  2. Only set AUTH_URL when Auth.js lives under a different base path
  3. Redeploy

works with next-auth 5.0.0-beta.32 · @auth/core 0.41.3 · Next.js 16.4.3last verified

Prompt for Cursor or Claude Code

After deploying, sign-in sends users to localhost. Find every place AUTH_URL or NEXTAUTH_URL is set or read, and tell me which ones to remove for production on Auth.js v5.

Not quite your error? Paste yours into the free VibeBoot Doctor or browse the Auth.js error fixer.

next: skip the next one

Skip the setup. The VibeBoot SaaS Starter ships Auth.js v5 already wired (GitHub sign-in, optional email magic links, Prisma adapter), plus Stripe and a database on Next.js 16.4.3. $49, one-time.

14-day money-back guarantee · lifetime updates

$ fixed it? get the next one first

New fixes for what AI agents break, by email.

When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.

Subscribe free