import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
const response = NextResponse.next()
// Add performance headers
response.headers.set('X-Edge-Location', process.env.VERCEL_REGION || 'unknown')
// Cache static assets aggressively
if (request.nextUrl.pathname.startsWith('/_next/static/')) {
response.headers.set(
'Cache-Control',
'public, max-age=31536000, immutable'
)
}
// Cache images for 1 year
if (request.nextUrl.pathname.startsWith('/images/')) {
response.headers.set(
'Cache-Control',
'public, max-age=31536000, immutable'
)
}
return response
}
export const config = {
matcher: [
'/((?!api|_next/static|_next/image|favicon.ico).*)',
],
}