fix: next js bug

This commit is contained in:
Benno Tielen 2026-02-28 08:33:32 +01:00
parent 996eafd0cb
commit 4db90f57df

View file

@ -1,24 +1,19 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
// next js bug
export function middleware(request: NextRequest) {
if (request.method === 'POST') {
console.log('[Middleware] POST request received', {
path: request.nextUrl.pathname,
method: request.method,
contentType: request.headers.get('content-type'),
userAgent: request.headers.get('user-agent'),
referer: request.headers.get('referer'),
nextAction: request.headers.get('next-action'),
accept: request.headers.get('accept'),
protocol: request.headers.get('x-forwarded-proto'),
ip: request.headers.get('x-forwarded-for'),
})
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 = {
matcher: ['/kontakt'],
// All pages with contact forms — exclude /api and /admin (Payload CMS)
matcher: ['/((?!api|admin|_next/static|_next/image|favicon.ico).*)'],
}