fix: revert proxy back to middleware for Next.js build compatibility
This commit is contained in:
35
src/middleware.ts
Normal file
35
src/middleware.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
const response = NextResponse.next();
|
||||
|
||||
const url = request.nextUrl.pathname;
|
||||
|
||||
if (
|
||||
url.startsWith("/sr") ||
|
||||
url.startsWith("/en") ||
|
||||
url.startsWith("/de") ||
|
||||
url.startsWith("/fr") ||
|
||||
url === "/"
|
||||
) {
|
||||
if (
|
||||
!url.includes("/checkout") &&
|
||||
!url.includes("/cart") &&
|
||||
!url.includes("/api/")
|
||||
) {
|
||||
response.headers.set(
|
||||
"Cache-Control",
|
||||
"public, max-age=3600, stale-while-revalidate=86400"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
"/((?!_next/static|_next/image|favicon.ico|icon.png|robots.txt|sitemap.xml).*)",
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user