nextauthjs / nextauthjs/next-auth
Signin URL does not respect reverse proxy headers
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
Environment
System:
OS: Linux 6.6 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (24) x64 AMD Ryzen 9 3900XT 12-Core Processor
Memory: 17.18 GB / 23.42 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 23.7.0 - ~/.nvm/versions/node/v23.7.0/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.9.2 - ~/.nvm/versions/node/v23.7.0/bin/npm
pnpm: 10.13.1 - /usr/local/bin/pnpm
bun: 1.1.20 - ~/.bun/bin/bun
npmPackages:
@auth/unstorage-adapter: ^2.0.0 => 2.10.0
next: latest => 15.4.5
next-auth: beta => 5.0.0-beta.29
react: ^18.2.0 => 18.3.1
Reproduction URL
https://github.com/jeengbe/nextauth-reverse-proxy-bug
Describe the issue
While createActionUrl respects proxy headers such as x-forwarded-host, the signin URLs for providers themselves do not: https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/lib/utils/providers.ts#L28
In the repro, signing in with Google links to http://0.0.0.0:3000/auth/... (since that's what Next.js is bound to), and running in Kubernetes (where a reverse proxy is the norm), you get links like https://cms-app-658c44c5d9-m2wx5:8080/api/auth/signin/google
How to reproduce
see repo
Expected behavior
It should also respect proxy headers.
This affects basically all .origin uses, e.g. https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/index.ts#L194
While it does work with AUTH_URL, that is not something that should be required to configure, given the information is there at runtime (headers).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/core/src/lib/utils/providers.ts, where provider sign-in URLs are built, and compare it with createActionUrl and the logic referenced in packages/core/src/index.ts. Reproduce the issue using the linked repository behind a reverse proxy, then verify that provider URLs and other affected .origin uses respect proxy headers without requiring AUTH_URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, typescript
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100