You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For domain-based routing, I think defaultLocale at the top-level is overriding the defaultLocale at the domain level, which I'm convinced is the wrong way around based on the documentation.
I've made a repo (a fork of next-intl) to demonstrate this using the example-app-router example. By the way thanks for your work on next-intl. It's brilliant!
Verifications
I've verified that the problem I'm experiencing isn't covered in the docs.
I've searched for similar, existing issues on GitHub and Stack Overflow.
These steps can be further extended to demonstrate the correct behaviour if defaultLocale is not set at the top-level:
Comment line 5 in middleware.ts (// defaultLocale: 'en',)
curl -IL localhost:3000
Redirect goes to /de as expected
I suspect the problem is inheritance in the structure generally. You'll note in my example that I had to define locales in each domain. These too should be inheritted from the top-level, but if they're not explicitly set in each domain, an undefined redirect loop occurs:
Comment line 13 in middleware.ts (// locales)
curl -IL localhost:3000
Redirect goes to /undefined/undefined/undefined/undefined/...
… instead of the top-level one in case no other locale matches better on the domain (#1000)
Fixes#998
Note that the `defaultLocale` of a domain is used if no other locale
matches better. However, if a domain supports multiple locales, the
best-matching one will be selected based on the `accept-language`
header. If you want to always use the `defaultLocale` in case no prefix
is provided, then you can turn off `localeDetection`.
Description
For domain-based routing, I think
defaultLocale
at the top-level is overriding the defaultLocale at the domain level, which I'm convinced is the wrong way around based on the documentation.I've made a repo (a fork of next-intl) to demonstrate this using the
example-app-router
example. By the way thanks for your work on next-intl. It's brilliant!Verifications
Mandatory reproduction URL
https://github.com/cleverlight/next-intl/blob/bugreport-defaultLocale-undefined/examples/example-app-router/src/middleware.ts
Reproduction description
Steps to reproduce:
bugreport-defaultLocale-undefined
curl -IL localhost:3000
These steps can be further extended to demonstrate the correct behaviour if defaultLocale is not set at the top-level:
middleware.ts
(// defaultLocale: 'en',
)curl -IL localhost:3000
I suspect the problem is inheritance in the structure generally. You'll note in my example that I had to define
locales
in each domain. These too should be inheritted from the top-level, but if they're not explicitly set in each domain, anundefined
redirect loop occurs:middleware.ts
(// locales
)curl -IL localhost:3000
Expected behaviour
The documentation states:
I would expect top-level
defaultLocale
orlocales
to be used if they're not defined in thedomains: []
entry.The text was updated successfully, but these errors were encountered: