AuthJS do not redirect to set URL, instead it redirect to Docker container internal IP #8449
Replies: 15 comments 19 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.
-
Environment
System:
OS: Windows 10 10.0.19045
CPU: (12) x64 Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
Memory: 7.73 GB / 31.71 GB
Binaries:
Node: 20.5.0 - C:\Program Files\nodejs\node.EXE
npm: 9.8.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.6.12 - ~\AppData\Local\pnpm\pnpm.EXE
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (116.0.1938.54)
Internet Explorer: 11.0.19041.1566
Reproduction URL
Describe the issue
When 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.
I'm using the app router:
Tried the suggested solutions in this thread but it does not work.
.env:
docker-compose.yaml:
Docker:
auth-api-route:
middleware:
How to reproduce
Setup NextJS with AuthJS with latest versions.
Then setup a basic docker and dockercompose file.
Expected behavior
Should redirect to set environment variable.
Beta Was this translation helpful? Give feedback.
All reactions