Files
fristydev/proxy.ts
T
fristy ad943fff8c
Build & Push / Lint & Build (push) Successful in 1m15s
Build & Push / Build & Push Image (push) Successful in 52s
Initial commit: fristy.net personal site
2026-09-10 04:59:12 +03:00

24 lines
713 B
TypeScript

import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { LOCALE_COOKIE, matchLocale } from "./lib/i18n/locales";
export function proxy(request: NextRequest) {
if (request.cookies.has(LOCALE_COOKIE)) {
return NextResponse.next();
}
const locale = matchLocale(request.headers.get("accept-language"));
const response = NextResponse.next();
response.cookies.set(LOCALE_COOKIE, locale, {
path: "/",
maxAge: 60 * 60 * 24 * 365,
sameSite: "lax",
});
return response;
}
export const config = {
matcher: [
"/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp|ico)).*)",
],
};