AuthJS do not redirect to set URL, instead it redirect to Docker container internal IP #8449
-
EnvironmentSystem: Reproduction URLDescribe the issueWhen using nextJS and authJS I get redirected to the internal ip-address of Docker instead of set environment variable when trying to access protected urls. Tried the suggested solutions in this thread but it does not work. .env:
docker-compose.yaml:
Docker:
auth-api-route:
middleware:
How to reproduceSetup NextJS with AuthJS with latest versions. Expected behaviorShould redirect to set environment variable. |
Beta Was this translation helpful? Give feedback.
Replies: 17 comments 22 replies
-
Encounter the same issue... After some research, seems like it is related to vercel/next.js#37536
Still under investigation... |
Beta Was this translation helpful? Give feedback.
-
managed to work when set custom signIn page const authUrl = process.env['NEXTAUTH_URL'] ?? 'http://localhost:3000';
export default withAuth({
pages: {
signIn: `${authUrl}/api/auth/signin`
}
}); but I don't think this is a solution ... |
Beta Was this translation helpful? Give feedback.
-
This is definitely an issue. All I did was |
Beta Was this translation helpful? Give feedback.
-
have in .env |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
any updates on this? |
Beta Was this translation helpful? Give feedback.
-
I just hit this too. Anyone have any idea? |
Beta Was this translation helpful? Give feedback.
-
Downgrade nextjs back to v13.4.12 and everything works fine. Plus I also added |
Beta Was this translation helpful? Give feedback.
-
try this. work for me (production too) i have some problem. the first one is next-auth always redirect to internal docker ip. so, i do this
now, the redirect is going to ip given. not worked with DNS. so i do this
example:
its worked but 'bad gateway' appear. after some search, i found this problem is from NGINX. so i do this
add this into your nginx.conf in http section
i hope this work for you too |
Beta Was this translation helpful? Give feedback.
-
Shouldn't this be a bug instead of a discussion, @balazsorban44? Especially, given that it used to work without applying a band-aid? I've worked with a lot of different frameworks over the years, but never have I had to explicitly set my hostname to |
Beta Was this translation helpful? Give feedback.
-
any update for this issuess? |
Beta Was this translation helpful? Give feedback.
-
Same issue here using |
Beta Was this translation helpful? Give feedback.
-
I'm facing the same issue. Currently, I'm using version "^5.0.0-beta.15" of next-auth with the Keycloak provider. Even after setting up all the suggested environment variables, I'm unable to proceed with authentication. Keycloak keeps reporting an invalid redirect_uri error, pointing to the Docker's internal host. |
Beta Was this translation helpful? Give feedback.
-
We've updated today to Nextjs 14.2.2 and removed the env |
Beta Was this translation helpful? Give feedback.
-
I got the same issue. On the website is written that AUTH_URL is not needed but without this I am redirecting to name of kubernetes pod instead to proper url website. I used dockerfile directly from next.js repo. I don't if this is important but I am also using AUTH_TRUST_HOST because of traefik. Summary:
#Extra info CMD ["node", "server.js"] |
Beta Was this translation helpful? Give feedback.
-
I'm running into this issue as well I managed to get a bit further by adding the authorization option to the Keycloak options and now it tries to login but I still end up with the I made a repo with instructions on how to reproduce the issue in docker and how everything just works when you run nextjs locally and keycloak in docker. Any help is appreciated, thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, we have an official section for deploying Docker here: https://authjs.dev/getting-started/deployment#docker It includes the recommended Docker config, and can be seen deployed (running on Render.com, but it should work the same everywhere) here: https://nextjs-docker-example.authjs.dev You should not need to set |
Beta Was this translation helpful? Give feedback.
Hi everyone, we have an official section for deploying Docker here: https://authjs.dev/getting-started/deployment#docker
It includes the recommended Docker config, and can be seen deployed (running on Render.com, but it should work the same everywhere) here: https://nextjs-docker-example.authjs.dev
You should not need to set
AUTH_URL
NEXTAUTH_URL
,NEXTAUTH_URL_INTERNAL
and the like anymore.