Replies: 1 comment 4 replies
-
I wonder if this is because a rewrite is like a proxy. Your browser is at a given URL, but the content it gets served belongs to a different source. I wonder if maybe you could try: const { pathname } = request.nextUrl
const { searchParams } = request.nextUrl
if (pathname.startsWith('/api')) {
return
}
const pathnameHasLocale = locales.some(
(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
)
if (!pathnameHasLocale) {
request.nextUrl.pathname = `/${DEFAULT_LOCALE}${pathname}`
return NextResponse.rewrite(request.nextUrl)
} Could you give this a go, and report back if it does something? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I have changing query param with nuqs. I use this library to achive shallow routing, without full page reload
And I have rewrite in middleware for handling locales:
matcher:
Finally I have a route
/pages/[lang]/tutoring/tutors/[id].tsx
where id reads by hook:
So untill I change query with nuqs - id returns correct string, but after changing query - id returns undefined.
If I remove
NextResponse.rewrite
it works as expected. How can I fix it?Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions