How to set up this rewrite to work in a certain way?
Answered
dperolio posted this in #help-forum
dperolioOP
Hello, I'm trying to set up internationalization. I've added all of my page routes inside of app/[lang]. The thing is, I want the default to be
This rewrite accomplishes that, but it also makes all other langs not work, e.g. /nl/products:
Do you know how I can fix the behavior?
en and when it is en (e.g. /en/products), I want to rewrite the URL to not include /en, so it would just be /products. Essentially, I don't ever want to see /en.This rewrite accomplishes that, but it also makes all other langs not work, e.g. /nl/products:
async rewrites () {
return [
{
source: '/:path*',
destination: '/en/:path*'
}
];
}Do you know how I can fix the behavior?
Answered by Sun bear
You asked for what Chat Gpt would say, here's what it said, may wanna try it.
5 Replies
dperolioOP
I think it will involve using
And then I set the value of
has: [
{
type: 'header',
key: 'accept-language',
value:
}
]And then I set the value of
accept-language in the middleware. I'm not sure how to set up the value regex in the rewrite though.dperolioOP
I guess that won't work, since you can't modify the header, and the header doesn't necessarily match the lang path.
dperolioOP
Open to other ideas. Maybe just set up the rewrite in my hosting provider (Netlify) instead?
Sun bear
You asked for what Chat Gpt would say, here's what it said, may wanna try it.
Answer
dperolioOP
ChatGPT too smart. Thanks, I didn't consider that. That solved it.