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:
JJ Kasper 2020-12-04 07:32:50 -06:00 committed by GitHub
parent 42385f48db
commit e6c1aa6483
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 3 deletions

View file

@ -178,7 +178,7 @@ module.exports = {
### Headers with i18n support ### 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 ```js
module.exports = { 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',
},
],
},
] ]
}, },
} }

View file

@ -122,7 +122,7 @@ module.exports = {
### Redirects with i18n support ### 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 ```js
module.exports = { module.exports = {
@ -145,6 +145,13 @@ module.exports = {
locale: false, locale: false,
permanent: false, permanent: false,
}, },
{
// this matches '/' since `en` is the defaultLocale
source: '/en',
destination: '/en/another',
locale: false,
permanent: false,
},
] ]
}, },
} }

View file

@ -166,7 +166,7 @@ module.exports = {
### Rewrites with i18n support ### 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 ```js
module.exports = { module.exports = {
@ -187,6 +187,12 @@ module.exports = {
destination: '/nl/another', destination: '/nl/another',
locale: false, locale: false,
}, },
{
// this matches '/' since `en` is the defaultLocale
source: '/en',
destination: '/en/another',
locale: false,
},
] ]
}, },
} }