Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 721 Bytes

middleware-new-signature.md

File metadata and controls

35 lines (27 loc) · 721 Bytes

Middleware new signature

Why This Error Occurred

Your application is using a Middleware function and your are using its parameters as with the deprecated API.

import { NextResponse } from 'next/server'

export function middleware(event) {
  if (event.request.nextUrl.pathname === '/blocked') {
    event.respondWith(
      new Response(null, {
        status: 403,
      })
    )
  }
}

Possible Ways to Fix It

You can use the Middleware function with the most recent API:

import { NextResponse } from 'next/server'

export function middleware(request) {
  if (request.nextUrl.pathname === '/blocked') {
    return new Response(null, {
      status: 403,
    })
  }
}