import type { NextRequest } from 'next/server' ; export function middleware ( req ) { const headers = new Headers ( { 'x-custom-1' : 'value-1' } ) ; headers . set ( 'x-custom-2' , 'value-2' ) ; const res = new Response ( null , { headers } ) ; res . headers . set ( 'x-custom-3' , 'value-3' ) ; return new Response ( 'Open the network tab in devtools to see the response headers' , { headers : { ... Object . fromEntries ( res . headers ) , 'x-custom-4' : 'value-4' , } , } ) ; }