NextAuth not working with nginx reverse proxy #8089
Unanswered
drmittelstein
asked this question in
Help
Replies: 3 comments 2 replies
-
Resolved - it turns out to have been an issue with the environmental variables not being properly loaded in the DockerFile and docker-compose.yml instructions |
Beta Was this translation helpful? Give feedback.
0 replies
-
Did you set your |
Beta Was this translation helpful? Give feedback.
2 replies
-
I have tried with AUTH_TRUST_HOST =http://localhost:3000 as the application was running in http://localhost:3000 in pm2, it worked for me |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey all, my NextAuth implementation works locally but not when I deploy to my server with a nginx reverse proxy.
I deployed my NextJS app (the T3 demo) app using docker-compose to a bare metal linux server, following this tutorial (https://www.digitalocean.com/community/tutorials/how-to-secure-a-containerized-node-js-application-with-nginx-let-s-encrypt-and-docker-compose) to setup with HTTPS via nginx.
The Discord provider that works fine locally in developer mode (localhost:3000). But, when I deploy it through docker-compose,
while every other feature works as expected, when I press the login button from the , I get navigated to MYDOMAIN/api/auth/error, and an HTML page returns with the text "Internal Server Error". There is nothing on the server side or client side console about this error.
My .env file has
NEXTAUTH_SECRET="..."
NEXTAUTH_URL="https://mydomain/"
NEXTAUTH_URL_INTERNAL="https://website.ip.address/"
My discord provider has the following redirect URIs
http://localhost:3000/api/auth/callback/discord
https://mydomain/api/auth/callback/discord
I'm thinking there is something going on with the reverse proxy of nginx that's messing with nextauth. Let me know if anything in the attached nginx.conf file would cause this problem, or if there is any simple error.
nginx.conf.txt
Beta Was this translation helpful? Give feedback.
All reactions