-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware.ts
28 lines (22 loc) · 942 Bytes
/
middleware.ts
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
import createIntlMiddleware from 'next-intl/middleware';
import { NextRequest } from 'next/server';
export default async function middleware(request: NextRequest) {
const localesary = require('/public/locales/langs.json').langs.map((x: any) => x.value);
const defaultLocale = request.headers.get('x-default-locale') ?? 'en';
const handleI18nRouting = createIntlMiddleware({
locales: localesary,
defaultLocale,
localePrefix: 'always',
alternateLinks: true,
localeDetection: true,
});
const response = handleI18nRouting(request);
response.headers.set('x-default-locale', defaultLocale);
return response;
}
export const config = {
// Skip all paths that should not be internationalized. This example skips
// certain folders and all pathnames with a dot (e.g. favicon.ico)
// matcher: ['/((?!api|_next|_vercel|.*\\..*).*)']
matcher: ['/((?!_next|api|backend|_next|_vercel|assets|.*\\..*).*)']
};