Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[i18n + redirects] defaultLocale not stripped from destination url #20106

Closed
wadehammes opened this issue Dec 11, 2020 · 2 comments
Closed

[i18n + redirects] defaultLocale not stripped from destination url #20106

wadehammes opened this issue Dec 11, 2020 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@wadehammes
Copy link

wadehammes commented Dec 11, 2020

Bug report

Describe the bug

When creating a redirect:

module.exports = {
  i18n: {
    locales: ["en", "es"],
    defaultLocale: "en",
  },
  async redirects() {
    return [
      {
        source: "/about",
        destination: "/about/our-story",
        permanent: false,
      },
    ];
  },
};

The redirect happens fine, however the destination URL in the browser is /en/about/our-story which is not great since this will break SEO.

Adding locale: false makes the redirect not happen at all.

To further add, logging out router on this page actually shows asPath as /about/our-story even though the path clearly has en in it.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Have internalization set up with next.config.js setup like above
  2. Create a redirect

Expected behavior

defaultLocale should not be present in the url, as with all other non-redirected links.

System information

  • OS: Windows
  • Browser (if applies): Edge
  • Version of Next.js: 10.0.3
  • Version of Node.js: 14.15.1
  • Deployment: Vercel
@wadehammes wadehammes added the bug Issue was opened via the bug report template. label Dec 11, 2020
@wadehammes wadehammes changed the title [i18n + redirects] default locale not stripped from destination url [i18n + redirects] defaultLocale not stripped from destination url Dec 11, 2020
@wadehammes
Copy link
Author

wadehammes commented Dec 17, 2020

Anything on this? Would love some insight into if this is a problem with my setup or a problem with Next.js. Looks like this will be solved in #19766

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants