Open neotrow opened 1 year ago
I think I found part of the issue:
https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/next/middleware.ts#L151
Here the locale
from the nexUrl
is not used.
It should be ${basePath}${locale}${pathname}${search}
.
The defaultLocale
is also supplied in the nextUrl
. So I would say it makes sense to not include the locale if it's equal to the defaultLocale
.
I can open a PR if that helps.
This would fix part one of my expected behaviour.
For part two I guess the signInPage
should be prefixed with locale
from nextUrl
. Again it would make sense to only do this if it's not the default locale.
Environment
System: OS: Windows 10 10.0.22621 CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K Memory: 12.75 GB / 31.78 GB Binaries: Node: 18.16.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.22621.1992.0), Chromium (115.0.1901.188) Internet Explorer: 11.0.22621.1
Reproduction URL
https://github.com/neotrow/next-auth-locale-bug
Describe the issue
It seems that the locale is stripped out of the callbackUrl. Also with a custom signIn page the locale is not respected.
How to reproduce
locale is en-GB and defaultLocale is de-CH
sign out
in the header you will get redirected tohttp://localhost:3000/api/auth/signin?callbackUrl=%2F
but you should be redirect tohttp://localhost:3000/api/auth/signin?callbackUrl=%2Fen-GB
Expected behavior
I would expect two things:
http://localhost:3000/api/auth/signin?callbackUrl=%2Fen-GB
/my-sign-in-page
and i'm on/en-GB
. If I click on signOut I would expect to be redirects to/en-GB/my-sign-in-page