Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth.js v5: Providers showing localhost:3000 instead of production domain when deployed to VPS with Dokploy #1090

Open
subonedev opened this issue Jan 12, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@subonedev
Copy link

To Reproduce

I'm having an issue with Auth.js (NextAuth) v5 in my Next.js application when deploying with Dokploy on my VPS server. The providers' URLs are showing localhost:3000 instead of my production domain.

Environment:

  • Next.js 15
  • Auth.js (NextAuth) v5
  • Deployed using Dokploy
  • Running behind Cloudflare proxy

Issue:

When I check the /api/auth/providers endpoint in production, it shows:

{
  "google": {
    "id": "google",
    "name": "Google",
    "type": "oidc",
    "signinUrl": "http://localhost:3000/api/auth/signin/google",
    "callbackUrl": "http://localhost:3000/api/auth/callback/google"
  }
}
Expected behavior:
The URLs should show my production domain instead of localhost:3000.


How can I make Auth.js use my production domain instead of localhost while avoiding the Cloudflare error?

ps: cloudflare set to FULL ssl/tls

### Current vs. Expected behavior

What I've tried:

Setting environment variables:

NEXT_PUBLIC_APP_URL=https://mydomain.com
AUTH_SECRET=[my-secret]
AUTH_TRUST_HOST=true

The same setup works correctly when deployed to Vercel, but fails on my VPS server deployment.
When I add AUTH_URL=https://mydomain.com to env in production:

The providers show the correct domain:

{
  "google": {
    "id": "google",
    "name": "Google",
    "type": "oidc",
    "signinUrl": "http://mydomain.com/api/auth/signin/google",
    "callbackUrl": "http://mydomain.com/api/auth/callback/google"
  }
}

BUT Cloudflare returns error 10000 on the homepage

### Provide environment information

```bash
NEXT_PUBLIC_APP_URL=https://mydomain.com
AUTH_SECRET=[my-secret]
AUTH_TRUST_HOST=true
AUTH_URL=https://mydomain.com

Which area(s) are affected? (Select all that apply)

Installation, Application, Traefik, Docker, Remote server

Are you deploying the applications where Dokploy is installed or on a remote server?

Remote server

Additional context

Ubuntu 22.04 LTC

Will you send a PR to fix it?

No

@subonedev subonedev added the bug Something isn't working label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant