-
In opposite of the thread [i18n] Prefix for default locale, how can you make sure that the defaultLocale is always stripped from the url? If you have for example three locales Getting the defaultLocale in the url is possible for example by having a link on the website (or some referring site) that has the defaultLocale as part of the url. We see quite some hits from Google that come in this way. As a possible solution I tried a redirect in I also found a way of using export async function getServerSideProps(context) {
const NextRequestMetaSymbol = Reflect.ownKeys(context.req).find(
(key) => key.toString() === 'Symbol(NextRequestMeta)',
);
if (
NextRequestMetaSymbol &&
context.req[NextRequestMetaSymbol] &&
context.req[NextRequestMetaSymbol].__nextStrippedLocale
) {
return {
redirect: { destination: context.req.url, permanent: false },
};
}
// do more interesting stuff here...
} I am out of options at this point, curios if anyone has had the same "problem" and/or has any ideas on this. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I also found this comment that basically says there should always be a redirect. It does not tell though if it also goes for urls like |
Beta Was this translation helpful? Give feedback.
-
When using the /pages folder, I found it better to use the suggested method in #18419 in stead of always trying to strip it. That would also make it easier when using the new app directory. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
When using the /pages folder, I found it better to use the suggested method in #18419 in stead of always trying to strip it. That would also make it easier when using the new app directory.