Replies: 3 comments 8 replies
-
As a temporary solution, I can use custom middleware:
But I'm not sure if this is a good solution( |
Beta Was this translation helpful? Give feedback.
-
Guessing here, you likely need https://next-auth.js.org/configuration/options#nextauth_url_internal |
Beta Was this translation helpful? Give feedback.
-
I'm having this same exact issue. I found the same line of code you did. I got around the issue by writing code in the redirect callback configured in the [...nextauth] middleware file. The callbackUrl in the browser still shows localhost, but the code takes the fallback URL that next-auth would typically use and creates a new URL taking the path, querystring, and hash from the client provided url and adding it to the baseUrl (which I believe is configured via the NEXTAUTH_URL environment variable). Anyways, here's my code:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
Hi guys!
My application is deployed on a custom vps server with nginx proxy.
When I use _middleware I get incorrect callbackUrl if the user is not authorized. callbackUrl starts with http://localhost instead of https://mysite.com
How to reproduce ☕️
I use nginx configuration:
Also I am using mysite.com/pages/admin/_middleware.ts
_middleware.ts code is:
If the user is not logged in, he is redirected to the login page.
next-auth/packages/next-auth/src/next/middleware.ts
Line 94 in a7c55b7
The problem is that req.url in my case is localhost:3000 and callbackUrl is localhost:3000/admin
By default redirect callback is
As a result, the user is taken to the page mysite.com/auth/signIn?callbackUrl=mysite.com instead of
mysite.com/auth/signIn?callbackUrl=mysite.com/admin
Can someone help solve this problem?
Thanks!
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Beta Was this translation helpful? Give feedback.
All reactions