redirect
from createSharedPathnamesNavigation
doesn't handle relative paths
#1177
Closed
3 tasks done
Labels
Description
When using
createSharedPathnamesNavigation
with app router, the exportedredirect
function doesn't handle relative redirects.For example, if the URL is
/[locale]/foo/bar/baz
, and we callredirect(.)
inpage.tsx
, I would expect to be taken to/[locale]/foo/bar
. This works with the built-in Nextredirect
functionIn this scenario, the
next-intl
redirect
function will instead change the URL to[locale].
(e.g./de.
)My team has worked around this by creating a custom
redirect
function that wraps the one fromcreateSharedPathnamesNavigation
to handle this specific scenario (and also work around TSnever
issues as mentioned in #823 ), so no huge urgency to fix. But I wanted to raise this bug in the hope that it could be fixed innext-intl
and we can remove our workarounds in the future.Verifications
Mandatory reproduction URL
Attached as ZIP file as company policy prevents me from deploying this anywhere
next-intl-redirect-bug-reproduction.zip
Reproduction description
Steps to reproduce:
npm install
npx next dev
http://localhost:3000/en/redirect/to/parent/next-intl
User is redirected to
http://localhost:3000/en.
Expected behaviour
Expected that user should be redirected to
http://localhost:3000/en/redirect/to/parent
. You can see this by going tohttp://localhost:3000/en/redirect/to/parent/next
, which uses theredirect
function fromnext/navigation
rather than thenext-intl
verisonThe text was updated successfully, but these errors were encountered: