Aleister
I'm having an issue with Auth.js (NextAuth) v5 in my Next.js application when deploying with Dokploy
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:
```json
{
"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.
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
How can I make Auth.js use my production domain instead of localhost while avoiding the Cloudflare error?
ps: cloudflare set to FULL ssl/tls14 replies