church-website/src/middleware.ts
2026-02-28 08:33:32 +01:00

19 lines
599 B
TypeScript

import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
// next js bug
export function middleware(request: NextRequest) {
if (request.method === 'POST') {
if (!request.headers.has('next-action')) {
console.log('[Middleware] Blocked POST without Next-Action header')
return new NextResponse('Method Not Allowed', { status: 405 })
}
}
return NextResponse.next()
}
export const config = {
// All pages with contact forms — exclude /api and /admin (Payload CMS)
matcher: ['/((?!api|admin|_next/static|_next/image|favicon.ico).*)'],
}