router.pathname rewrite similar to middleware
Unanswered
African Slender-snouted Crocodil… posted this in #help-forum
African Slender-snouted CrocodileOP
I am trying to achieve the following:
- my-website.com/us -> the US personalized website
- my-website.com -> the Global personalized website
And I want to handle the languages through a query parameter and cookies only, not through the path
Currently i've achieved this by disabling i18n path and adding rewrite in my middleware to remove the "prefix" /us so that Next.js renders the correct page.
My only remaining issue right now is that when i get router.pathname, it returns the wrong route now. Let's say i am on /us/checkout page, it will return /[...alias].
Is there any way to rewrite the router.pathname as well?
- my-website.com/us -> the US personalized website
- my-website.com -> the Global personalized website
And I want to handle the languages through a query parameter and cookies only, not through the path
Currently i've achieved this by disabling i18n path and adding rewrite in my middleware to remove the "prefix" /us so that Next.js renders the correct page.
My only remaining issue right now is that when i get router.pathname, it returns the wrong route now. Let's say i am on /us/checkout page, it will return /[...alias].
Is there any way to rewrite the router.pathname as well?