fix: next js bug
This commit is contained in:
parent
996eafd0cb
commit
4db90f57df
1 changed files with 7 additions and 12 deletions
|
|
@ -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).*)'],
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue