Skip to content

Malformed sign-in link on default error page #13204

@hinaloe

Description

@hinaloe

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

  1. Open https://next-auth-example.vercel.app/auth/error?error=AccessDenied

or

  1. try sign in some provider

  2. IdP reject signin and redirect to AccessDenied page

  3. Click signin button

  4. Jump to invalid page

Expected behavior

back to correct signin page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions