Skip to content
Discussion options

You must be logged in to vote

@setoelkahfi this is a reverse proxy + Auth.js v5 protocol detection issue. auth.js constructs the redirect_uri from the request URL's origin. behind PM2/nginx, Next.js sees http://localhost:3022 as the origin, and if AUTH_URL doesn't properly override it, Apple gets http:// in the redirect.

two things to check:

1. make sure nginx forwards the protocol header:

location / {
    proxy_pass http://localhost:3022;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

X-Forwarded-Proto is the critical one. without it, auth.js falls back to the raw request p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@setoelkahfi
Comment options

Answer selected by setoelkahfi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants