[i18n] explicit access to /en not redirecting to /
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.5k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
What version of Next.js are you using?
10.0.5
What version of Node.js are you using?
14.15.0
What browser are you using?
Chrome
What operating system are you using?
Windows 10
How are you deploying your application?
next dev (localhost)
Describe the Bug
According to docs when enabling i18n with following config:
module.exports = {
i18n: {
locales: ['en-US', 'fr', 'nl-NL'],
defaultLocale: 'en-US',
},
}
only available URLs should be:
/blog
/fr/blog
/nl-nl/blog
but if I try to access page explicitly specifing default locale (i.e. /en-US) then it will show page as is, without being redirected to /
Expected Behavior
It should redirect all paths prefixed with default locale to non-prefixed paths (i.e. /en to /, /en/hello to /hello etc).
I would like to get rid of duplicated pages, because it potentially can bring problems with SEO.
Also, I couldn't fix it using redirects section because it runs into infinite loop (ERR_TOO_MANY_REDIRECTS ):
async redirects() {
return [
{
source: '/en',
destination: '/',
locale: false,
permanent: true,
},
{
source: '/en/:path*',
destination: '/:path*',
locale: false,
permanent: true,
}
];
},
To Reproduce
- Download and run official
i18n-routingexample - Try to access to
/en(default locale) and make sure it will show page without redirect
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the official i18n-routing example and request the default-locale paths described in the issue, including /en and /en/hello. Compare the observed behavior with the expected redirects to / and /hello; the work is done when default-locale-prefixed paths redirect without creating redirect loops.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs
- Domain
- internationalization, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100