Environment
System:
OS: macOS 15.4.1
CPU: (8) arm64 Apple M2
Memory: 83.70 MB / 24.00 GB
Shell: 4.0.2 - /opt/homebrew/bin/fish
Binaries:
Node: 24.5.0 - /opt/homebrew/bin/node
npm: 11.5.1 - /opt/homebrew/bin/npm
pnpm: 10.14.0 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 139.0.7258.155
Edge: 138.0.3351.77
Safari: 18.4```
Reproduction URL
https://github.com/hinaloe/next-auth-example-01
Describe the issue
On the default error page (e.g., /auth/error?error=AccessDenied), the "Sign In" link does not point to the correct sign-in page. Instead of linking to /auth/signin, it incorrectly appends "/signin" to the full error URL, resulting in a broken link like /auth/error?error=AccessDenied/signin.
This issue appears to be caused by improper URL construction in the error page component. The problematic code is located here:
|
const signinPageUrl = `${url}/signin` |
In this line, a string is directly appended to the url object, which includes the existing path and query parameters, leading to a malformed URL.
To generate the sign-in URL correctly, the path should be resolved relative to the base URL. This can be achieved by passing the url object as the base to the URL constructor, like so:
const signinPageUrl = new URL('signin', url);
How to reproduce
- Open https://next-auth-example.vercel.app/auth/error?error=AccessDenied
or
-
try sign in some provider
-
IdP reject signin and redirect to AccessDenied page
-
Click signin button
-
Jump to invalid page
Expected behavior
back to correct signin page.
Environment
Reproduction URL
https://github.com/hinaloe/next-auth-example-01
Describe the issue
On the default error page (e.g.,
/auth/error?error=AccessDenied), the "Sign In" link does not point to the correct sign-in page. Instead of linking to/auth/signin, it incorrectly appends "/signin" to the full error URL, resulting in a broken link like/auth/error?error=AccessDenied/signin.This issue appears to be caused by improper URL construction in the error page component. The problematic code is located here:
next-auth/packages/core/src/lib/pages/error.tsx
Line 25 in 39dd3b9
In this line, a string is directly appended to the
urlobject, which includes the existing path and query parameters, leading to a malformed URL.To generate the sign-in URL correctly, the path should be resolved relative to the base URL. This can be achieved by passing the
urlobject as the base to theURLconstructor, like so:How to reproduce
or
try sign in some provider
IdP reject signin and redirect to AccessDenied page
Click signin button
Jump to invalid page
Expected behavior
back to correct signin page.