Skip to content

Link to a protected page fails when using i18n routes with next 11.1.0 #464

@vitormv

Description

@vitormv

Describe the problem

When using the latest Next.js v11.1.0, and having i18n routes enabled, any <Link /> that points to a protected page will fail. In Next.js 11.1, they removed the locale prefix from api routes, but it seems Auth0 package is still trying to redirect to a locale prefixed route.

I tried setting up "NEXT_PUBLIC_AUTH0_LOGIN="/api/auth/login"" in the .env file. Also tried to manually set the login route in the , but the issue persists

What was the expected behavior?

User should be redirected to /api/auth/login instead of /en/api/auth/login.

Reproduction

I created a sample codebox where you can see the issue. Clicking on the regular <a> link works fine (ignore the error page on the Auth0 side). But trying to reach the same package when using a <Link /> leads to a redirect to api route with a prefix.

https://codesandbox.io/s/peaceful-smoke-0iubu

Of course, the external Auth0 login page will show an error since there are no correct Auth0 for a real project, but just reaching the page can be considered a "success" in this case.

Environment

    "@auth0/nextjs-auth0": "1.5.0",
    "next": "11.1.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs investigationThis needs to be investigated further before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions