Replies: 2 comments
-
Therefore no automatic redirect is done that would change the domain. You can however compose the middleware and add additional redirects on top if you like before the |
Beta Was this translation helpful? Give feedback.
-
Hi 👋 , I am also running into a similar issue with auto redirects to subdomains not working as expected. Expected:
Actually:
import { defineRouting } from 'next-intl/routing';
export const routing = defineRouting({
defaultLocale: 'en-US',
domains: [
{
defaultLocale: 'en-US',
domain: 'en.local.app.com',
locales: ['en-US'],
},
{
defaultLocale: 'pt-BR',
domain: 'pt.local.app.com',
locales: ['pt-BR'],
},
{
defaultLocale: 'es',
domain: 'es.local.app.com',
locales: ['es'],
},
],
localePrefix: { mode: 'never' },
locales: ['en-US', 'pt-BR', 'es'],
}); Important to note: When I set localePrefix to
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I want to create a nextjs i18 app with subdomain based locale, like-
example.com //It is default locale, on default locale I want to use en
fr.example.com
de.example.com
I don't want to use prefix like-
fr.example.com/fr
de.example.com/de
That's why disable the locale prefix. Following is my code-
i18n.ts
-middleware.ts
-So, here you can see that, I use this
localePrefix: "never",
. Now it is not auto redirecting.What I want?
I want to auto redirect to subdomain based routing without adding locale prefix. Suppose, detection locale is fr, but I am going to root domain
example.com
, it automatically should redirect tofr.example.com
.Again suppose, detection locale is en, but I am trying to go
fr.example.com
it should redirect toexample.com
, as here I want to use root domain for en locale.Same as, if I previously switch locale to fr, next-intl is saving this onto cookie, then I try to go
example.com
, it should redirect tofr.example.com
.Could anyone please help me, I need to understand the whole things. Please say or give minimal example, how can I do that?
Beta Was this translation helpful? Give feedback.
All reactions