How can I have root as defaultLocale (mixed-routing) and not redirect to /${defaultLocale} #1705
Unanswered
jeremybosma
asked this question in
Q&A
Replies: 3 comments 2 replies
-
Were you able to figure it out? The |
Beta Was this translation helpful? Give feedback.
2 replies
-
Did you find a solution for this? :) |
Beta Was this translation helpful? Give feedback.
0 replies
-
I don't know if this will come back to haunt me later, but: Adjusting request.nextUrl.pathname to the defaultLocale when the root-path is being requested does the trick! import createMiddleware from 'next-intl/middleware'
import { routing } from '@/i18n/routing'
const intlMiddleware = createMiddleware(routing)
export default async function middleware(request) {
if(request.nextUrl.pathname === "/") {
request.nextUrl.pathname = "/" + routing.defaultLocale
}
const response = await intlMiddleware(request)
return response
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I’m working on my app, but / (app/page.tsx) never works because of the [locale]/page.tsx.
I want / to default to English while still allowing /en to exist for explicit use. Additionally, if a user’s user agent is set to Dutch (nl), / should redirect accordingly but i should also be able to go to /en for the english version.
How can I achieve this?
Beta Was this translation helpful? Give feedback.
All reactions