Complete the code to import the NextResponse object from the correct module.
import { [1] } from 'next/server';
The NextResponse object is imported from next/server to create responses in middleware.
Complete the code to define a middleware function that receives a request.
export function middleware([1]) { return NextResponse.next(); }
The middleware function receives a request object representing the incoming request.
Fix the error in the middleware export syntax.
export function [1](request) { return NextResponse.next(); }
The middleware function must be named exactly middleware for Next.js to recognize it.
Fill both blanks to create a matcher that applies middleware only to API routes.
export const config = {
matcher: [1]
};
// Matches paths starting with [2]The matcher uses an array with the pattern "/api/:path*" to apply middleware to all API routes.
Fill all three blanks to create middleware that redirects users from '/' to '/home'.
import { NextResponse } from 'next/server'; export function middleware([1]) { if (request.nextUrl.pathname === [2]) { return NextResponse.redirect(new URL([3], request.url)); } return NextResponse.next(); }
The middleware checks if the path is '/' and redirects to '/home' using NextResponse.redirect.