mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 07:31:07 -05:00
25 lines
739 B
TypeScript
25 lines
739 B
TypeScript
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*',
|
|
]
|
|
}; |