Skip to content

Deployment issue with Route Handler #7229

@ryanhay

Description

@ryanhay

Environment

System:
OS: macOS 13.3.1
CPU: (10) arm64 Apple M1 Max
Memory: 16.40 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.15.0 - ~/Library/Caches/fnm_multishells/2264_1681008406169/bin/node
npm: 9.5.0 - ~/Library/Caches/fnm_multishells/2264_1681008406169/bin/npm
Browsers:
Brave Browser: 112.1.50.114
Chrome: 112.0.5615.49
Firefox Developer Edition: 112.0
Safari: 16.4

Reproduction URL

private repo

Describe the issue

When initialising NextAuth with the 'app dir' and the env variable AUTH_TRUST_HOST set the function detectHost always returns the default value 'http://localhost:3000'.

It seems the NextAuthRouteHandler uses the same method as the NextAuthApiHandler to get the host header.

Currently uses: req.headers["x-forwarded-host"] instead of req.headers.get('x-forwarded-host').

How to reproduce

Install 4.22 and initialise in the app dir with either AUTH_TRUST_HOST or VERCEL env vars set.

Expected behavior

When the env variable AUTH_TRUST_HOST is set the value of x-forwarded-host should be used instead of http://localhost:3000.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstreamThe issue dervies from one of next-auth dependencies

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions