mediahub-fe/middleware.ts

30 lines
941 B
TypeScript
Raw Normal View History

import createMiddleware from "next-intl/middleware";
import { NextRequest, NextResponse } from "next/server";
import { locales } from "@/config";
2025-05-22 09:53:54 +00:00
import { routing } from "./i18n/routing";
2024-11-26 03:09:48 +00:00
2025-05-22 09:53:54 +00:00
// export default async function middleware(request: NextRequest) {
// // Step 1: Use the incoming request (example)
// const defaultLocale = "in";
// // const defaultLocale = request.headers.get("dashcode-locale") || "in";
2025-05-22 09:53:54 +00:00
// // Step 2: Create and call the next-intl middleware (example)
// const handleI18nRouting = createMiddleware({
// locales: ["in", "en"],
// defaultLocale: "in",
// });
// const response = handleI18nRouting(request);
2024-11-26 03:09:48 +00:00
2025-05-22 09:53:54 +00:00
// // Step 3: Alter the response (example)
// response.headers.set("dashcode-locale", defaultLocale);
2024-11-26 03:09:48 +00:00
2025-05-22 09:53:54 +00:00
// return response;
// }
export default createMiddleware(routing);
2024-11-26 03:09:48 +00:00
export const config = {
// Match only internationalized pathnames
2025-05-22 09:53:54 +00:00
matcher: ["/", "/(in|en)/:path*"],
};