2024-09-11 23:53:26 +02:00
|
|
|
import { LOCALES, LOCALE_DEFAULT, LOCALE_PREFIX } from "@repo/utils/constants"
|
2024-07-30 23:59:06 +02:00
|
|
|
import createMiddleware from "next-intl/middleware"
|
|
|
|
|
|
|
|
export default createMiddleware({
|
|
|
|
locales: LOCALES,
|
|
|
|
defaultLocale: LOCALE_DEFAULT,
|
|
|
|
localePrefix: LOCALE_PREFIX,
|
|
|
|
})
|
|
|
|
|
|
|
|
export const config = {
|
|
|
|
matcher: [
|
|
|
|
// Enable a redirect to a matching locale at the root
|
|
|
|
"/",
|
|
|
|
|
|
|
|
// Set a cookie to remember the previous locale for
|
|
|
|
// all requests that have a locale prefix
|
2024-07-31 11:41:39 +02:00
|
|
|
// Next.js issue, middleware matcher should support template literals:
|
|
|
|
// https://github.com/vercel/next.js/issues/56398
|
2024-07-30 23:59:06 +02:00
|
|
|
"/(en-US|fr-FR)/:path*",
|
|
|
|
|
|
|
|
// Enable redirects that add missing locales
|
|
|
|
// (e.g. `/pathnames` -> `/en/pathnames`)
|
|
|
|
"/((?!_next|_vercel|.*\\..*).*)",
|
|
|
|
],
|
|
|
|
}
|