-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiddleware.js
31 lines (27 loc) · 907 Bytes
/
middleware.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { NextResponse } from 'next/server'
import { i18nRouter } from 'next-i18n-router';
import i18nConfig from './i18nConfig';
export function middleware(request) {
return i18nRouter(request, i18nConfig);
// Check if there is any supported locale in the pathname
// const pathname = request.nextUrl.pathname
// const pathnameIsMissingLocale = locales.every(
// (locale) => !pathname.startsWith(`/${locale}/`) && pathname !== `/${locale}`
// )
// // Redirect if there is no locale
// if (pathnameIsMissingLocale) {
// // e.g. incoming request is /products
// // The new URL is now /en-US/products
// return NextResponse.redirect(
// new URL(`/eng/${pathname}`, request.url)
// )
// }
}
export const config = {
matcher: [
// Skip all internal paths (_next)
'/((?!_next|favicon\\.ico).*)',
// Optional: only run on root (/) URL
// '/'
],
}