Unverified Commit 979da913 authored by Lee Robinson's avatar Lee Robinson Committed by GitHub
parent 41bedf67
...@@ -173,19 +173,18 @@ import { NextRequest, NextResponse } from 'next/server' ...@@ -173,19 +173,18 @@ import { NextRequest, NextResponse } from 'next/server'
const PUBLIC_FILE = /\.(.*)$/ const PUBLIC_FILE = /\.(.*)$/
export function middleware(request: NextRequest) { export async function middleware(req: NextRequest) {
const shouldHandleLocale = if (
!PUBLIC_FILE.test(request.nextUrl.pathname) && req.nextUrl.pathname.startsWith('/_next') ||
!request.nextUrl.pathname.includes('/api/') && req.nextUrl.pathname.includes('/api/') ||
request.nextUrl.locale === 'default' PUBLIC_FILE.test(req.nextUrl.pathname)
) {
if (shouldHandleLocale) { return
const url = request.nextUrl.clone()
url.pathname = `/en${request.nextUrl.pathname}`
return NextResponse.redirect(url)
} }
return undefined if (req.nextUrl.locale === 'default') {
return NextResponse.redirect(new URL(`/en${req.nextUrl.pathname}`, req.url))
}
} }
``` ```
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment