3

I'm using NextJS 14 and next-intl. I'm implementing localized pathnames (https://next-intl-docs.vercel.app/docs/routing#pathnames)

In my NextJS Middleware, I'm checking if I'm in a route like: request.url.includes(routes.initialize.replace('/', ''))

But with localized pathnames I can't do it, because of course, the pathname is localized.

I've been searching in the documentation (https://next-intl-docs.vercel.app/docs/routing/navigation#apis) of next-intl and I didn't find any method to get the original pathname given a localized pathname.

There is a hook that is named "usePathname" (https://next-intl-docs.vercel.app/docs/routing/navigation#usepathname) but I can't run it in the middleware.

Anyone that have found any solution?

I've tried to build a func to get the original pathname but there are complex paths.

1
  • Have you found a solution? I'm in the same situation. Commented Nov 10, 2024 at 20:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.