Skip to content

Instantly share code, notes, and snippets.

@jasonbyrne
Created April 27, 2020 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonbyrne/35ab22815c00e7920afbf3ce0d44fcf4 to your computer and use it in GitHub Desktop.
Save jasonbyrne/35ab22815c00e7920afbf3ce0d44fcf4 to your computer and use it in GitHub Desktop.
Add custom header at edge that works on StackPath and Cloudflare
export async function addCustomHeader(response: Response): Promise<Response> {
const modifiedResponse = new Response(await response.arrayBuffer(), response);
modifiedResponse.headers.set("X-My-Custom-Header", "Hello there!");
return modifiedResponse;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment