Add locale: false custom route prefix note (#19765)
This makes sure to note how custom-routes need to be prefixed when `locale: false` is used for routes to be matched correctly. Closes: https://github.com/vercel/next.js/issues/19703
This commit is contained in:
parent
42385f48db
commit
e6c1aa6483
3 changed files with 27 additions and 3 deletions
|
@ -178,7 +178,7 @@ module.exports = {
|
|||
|
||||
### Headers with i18n support
|
||||
|
||||
When leveraging [`i18n` support](/docs/advanced-features/i18n-routing.md) with headers each `source` is automatically prefixed to handle the configured `locales` unless you add `locale: false` to the header:
|
||||
When leveraging [`i18n` support](/docs/advanced-features/i18n-routing.md) with headers each `source` is automatically prefixed to handle the configured `locales` unless you add `locale: false` to the header. If `locale: false` is used you must prefix the `source` with a locale for it to be matched correctly.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
|
@ -209,6 +209,17 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
// this matches '/' since `en` is the defaultLocale
|
||||
source: '/en',
|
||||
locale: false,
|
||||
headers: [
|
||||
{
|
||||
key: 'x-hello',
|
||||
value: 'world',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
},
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ module.exports = {
|
|||
|
||||
### Redirects with i18n support
|
||||
|
||||
When leveraging [`i18n` support](/docs/advanced-features/i18n-routing.md) with redirects each `source` and `destination` is automatically prefixed to handle the configured `locales` unless you add `locale: false` to the redirect:
|
||||
When leveraging [`i18n` support](/docs/advanced-features/i18n-routing.md) with redirects each `source` and `destination` is automatically prefixed to handle the configured `locales` unless you add `locale: false` to the redirect. If `locale: false` is used you must prefix the `source` and `destination` with a locale for it to be matched correctly.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
|
@ -145,6 +145,13 @@ module.exports = {
|
|||
locale: false,
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
// this matches '/' since `en` is the defaultLocale
|
||||
source: '/en',
|
||||
destination: '/en/another',
|
||||
locale: false,
|
||||
permanent: false,
|
||||
},
|
||||
]
|
||||
},
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ module.exports = {
|
|||
|
||||
### Rewrites with i18n support
|
||||
|
||||
When leveraging [`i18n` support](/docs/advanced-features/i18n-routing.md) with rewrites each `source` and `destination` is automatically prefixed to handle the configured `locales` unless you add `locale: false` to the rewrite:
|
||||
When leveraging [`i18n` support](/docs/advanced-features/i18n-routing.md) with rewrites each `source` and `destination` is automatically prefixed to handle the configured `locales` unless you add `locale: false` to the rewrite. If `locale: false` is used you must prefix the `source` and `destination` with a locale for it to be matched correctly.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
|
@ -187,6 +187,12 @@ module.exports = {
|
|||
destination: '/nl/another',
|
||||
locale: false,
|
||||
},
|
||||
{
|
||||
// this matches '/' since `en` is the defaultLocale
|
||||
source: '/en',
|
||||
destination: '/en/another',
|
||||
locale: false,
|
||||
},
|
||||
]
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue