Adding headers at the edge

In some cases we might want to add or modify the headers from an incoming request for different reasons, AB testing, personalization, analytics, etc. To have access to the tenative response we can call and then modify its headers:

// Store the response so we can modify its headers
const response =

// Set custom header

// Return response
return response

Open the network tab in devtools to see the response headers

x-modified-edge: true