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

Locale prefix treated as subroute + cannot disable localeDetection #44346

Closed
1 task done
apriltaoyvr opened this issue Dec 25, 2022 · 2 comments
Closed
1 task done

Locale prefix treated as subroute + cannot disable localeDetection #44346

apriltaoyvr opened this issue Dec 25, 2022 · 2 comments
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.

Comments

@apriltaoyvr
Copy link

apriltaoyvr commented Dec 25, 2022

Verify canary release

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

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Home
Binaries:
  Node: 18.12.1
  npm: N/A
  Yarn: N/A
  pnpm: 7.18.1
Relevant packages:
  next: 13.1.1
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

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

No response

Link to the code that reproduces this issue

Due to the difficulty of reproducing the yarn error, I am seperating the two issues.

https://github.com/apriltaoyvr/next13-yarn
https://github.com/apriltaoyvr/next-i18n-error

To Reproduce

Yarn Routing

  1. Clone the yarn example
  2. Run the dev server
  3. It will now 404 as the app/page.tsx file is skipped over
  4. Create app/[slug]/page.tsx
  5. It will no longer 404 but the app/page.tsx file will still be skipped over

Disabling localeDetection

  1. Run create-next-app@latest
  2. Add localeDetection: false to next.config.js
  3. Run dev server and see that it will not launch due to a console error (Error: Specified i18n.locales should be an Array received undefined)
  4. Then try adding locales: ['default', 'en', 'de', 'fr'], defaultLocale: 'default' to the config
  5. Run dev server
  6. See that it is still being routed to a locale

Describe the Bug

The two issues are related to localePrefixing, but due to the difficulty of reproducing the yarn error, I will describe them separately. It is impossible to work around the Yarn issue without creating a [locale] slug since you cannot disable localeDetection.

Yarn Routing

This is difficult to reproduce consistently. The yarn example above (hopefully) should work if cloned.

If a project is scaffolded with Yarn (3.3.1) and the app directory is enabled, the locale prefix will be treated as a subroute. A [locale] slug in the app dir is required for routing.

This issue seems to only happen when Next 13 app projects are scaffolded with Yarn. I did not encounter these issues when copying over these files to the other error example template (that was created with npm), which is the other reason why I have separated the examples.

localeDetection

You cannot disable localeDetection without a console error (Error: Specified i18n.locales should be an Array received undefined) in Next 13.1.1 (and 13.1.1-canary.1). Adding locales to circumvent it will still lead to the page being routed to a locale.

The issue also occurs with both the app and pages directory.

Expected Behavior

Yarn Routing

For the app/page.tsx file to be the default page and for the locale prefix to not be treated as a slug route. It is also odd that it is being prefixed in Yarn scaffolds as previous versions of Next 13's app directory do not have the prefixing.

localeDetection

To be able to disable internationalized routing as shown in the docs (https://nextjs.org/docs/advanced-features/i18n-routing#disabling-automatic-locale-detection).

Which browser are you using? (if relevant)

Version 109.0.5414.46 (Official Build) beta (64-bit)

How are you deploying your application? (if relevant)

No response

@apriltaoyvr apriltaoyvr added the bug Issue was opened via the bug report template. label Dec 25, 2022
@apriltaoyvr apriltaoyvr changed the title Cannot disable localeDetection on pages and app directory Locale prefix treated as subroute + cannot disable localeDetection Dec 26, 2022
@nextjs-bot
Copy link
Collaborator

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

@nextjs-bot nextjs-bot added the stale The issue has not seen recent activity. label Jan 18, 2025
@nextjs-bot
Copy link
Collaborator

This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!

@nextjs-bot nextjs-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2025
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. stale The issue has not seen recent activity.
Projects
None yet
Development

No branches or pull requests

2 participants