File size: 800 Bytes
743dad3
 
 
 
 
 
 
 
 
 
 
 
1e075e6
 
743dad3
 
 
81c35d1
743dad3
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";

export function middleware(request: NextRequest) {
  const headers = new Headers(request.headers);
  headers.set("x-current-host", request.nextUrl.host);
  
  const response = NextResponse.next({ headers });

  if (request.nextUrl.pathname.startsWith('/_next/static')) {
    response.headers.set('Cache-Control', 'public, max-age=31536000, immutable');
  }
  const canonicalBase = process.env.PUBLIC_BASE_URL || `https://${request.nextUrl.host}`;
  response.headers.set('X-Canonical-URL', `${canonicalBase}${request.nextUrl.pathname}`);
  
  return response;
}
// export function middleware(request: NextRequest) 
export const config = {
  matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
};