Skip to content

Latest commit

 

History

History
 
 

set-response-header

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Netlify examples

Set custom HTTP response headers with Netlify Edge Functions

Use an Edge Function to add HTTP headers to any HTTP response at The Edge.

Code example

Edge Functions are files held in the netlify/edge-functions directory.

import type { Context } from "https://edge.netlify.com";

export default async (request: Request, context: Context) => {
  const response = await context.next();
  response.headers.set("X-Your-Custom-Header", "A custom header value");
  return response;
};

View this example on the web

Deploy to Netlify

You can deploy this and all the other examples in this repo as a site of your own to explore and experiment with, by clicking this button.

Deploy to Netlify