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

Rewrites not working correctly with i18n config #50498

Open
1 task done
przemekga opened this issue May 29, 2023 · 1 comment
Open
1 task done

Rewrites not working correctly with i18n config #50498

przemekga opened this issue May 29, 2023 · 1 comment
Labels
bug Issue was opened via the bug report template.

Comments

@przemekga
Copy link

przemekga commented May 29, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #166-Ubuntu SMP Tue Apr 18 16:51:45 UTC 2023
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: 1.22.10
      pnpm: 8.6.0
    Relevant packages:
      next: 13.2.5-canary.17
      eslint-config-next: 13.2.5-canary.17
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

Internationalization (i18n)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/przemekga/rewrites-18n-bug-reproduction

To Reproduce

  1. Create new page in /pages.
  2. Add i18n config with domain containing at least 2 locales
i18n: {
    defaultLocale: "en",
    locales: ["en", "de"],
    localeDetection: false,
    domains: [
      {
        defaultLocale: "catchAll",
        domain: "localhost",
        http: true,
        locales: ["en", "de"],
      },
    ],
}
  1. Add rewrites that will point localized urls to newly added page
  async rewrites() {
    return [
      { source: "/de/de-test", destination: "/test", locale: false },
      { source: "/en/test", destination: "/test", locale: false },
    ];
  },
  1. Go to http://localhost:3000/de/de-test
  2. 404

Describe the Bug

Before this commit in v13.2.5-canary.17 b8d785d config like one in reproduction would result in localized urls in rewrites to point to correct page with correct locale then passed to getStaticProps/getServerSideProps context. After this commit rewrite with source: "/de/de-test" results in 404, changing rewrite source url part after locale to the same as page name in /pages ie. source: "/de/test" results in working rewrite.

Expected Behavior

i18n config and rewrites as in reproduction repo should result with url "/de/de-test" pointing to "/test" in /pages with locale passed to getStaticProps/getServerSideProps context as in versions before v13.2.5-canary.17

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@przemekga przemekga added the bug Issue was opened via the bug report template. label May 29, 2023
@paulvanbrenk
Copy link

Looks similar root issue i'm seeing with the appDir and middleware

#49883

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants