Modify Headers

This script shows how to modify both request and response headers

addEventListener("fetch", event => {
  event.respondWith(handleRequest(event.request));
});

async function handleRequest(request) {
  // Set request header
  request.headers.set("x-sp-serverless-request", "true");

  // send request
  const response = await fetch(request);

  // Set response header
  response.headers.set("x-sp-serverless-response", "true");

  return response;
}

What’s Next