import { NextResponse } from 'next/server'; import type { NextRequest } from 'next/server'; export async function middleware(request: NextRequest) { const response = NextResponse.next(); // Add additional headers response.headers.set('x-middleware-cache', 'no-cache'); // CORS headers for API routes if (request.nextUrl.pathname.startsWith('/api/')) { response.headers.set('Access-Control-Allow-Origin', '*'); response.headers.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); response.headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization'); } return response; } // Configure routes that need middleware export const config = { matcher: [ '/api/:path*', ] };