You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the documentation I was able get the hello world edge function running and to verify it via the netlify cli. However when I switch out the body of the test.ts file with response edge function to:
import type { Context } from "https://edge.netlify.com";
export default async (request: Request, context: Context) => {
const url = new URL(request.url);
if (url.searchParams.get("method") !== "set-response-header") {
return context.next();
}
context.log(`Adding a custom header to the response for ${url}`);
const response = await context.next();
response.headers.set("X-Your-Custom-Header", "Your custom header value");
return response;
};
and update the netlify.tomi to
[[edge_functions]]
path = "/*"
function = "hello"
I can see that the edge function is◈ Loaded edge function hello up via the --edgeInspect flag, but when inspected the page I do not see the reponse header. Connecting the debugger doesn't lead to much helpful information that I can see.
The text was updated successfully, but these errors were encountered:
kriordan37
changed the title
Unable to set Custom Response header
Unable to set Custom Response header via edge function
Sep 28, 2022
I also tried seperating it exactly how it is in this repo. so i created a file for the response function called `set-response-header.ts' and added to my netlify.toml
[[edge_functions]]
path = "/test"
function = "hello"
[[edge_functions]]
function = "set-response-header"
path = "/*"
the /test page is working but no where on the site am i getting the custom response header
Following the documentation I was able get the hello world edge function running and to verify it via the netlify cli. However when I switch out the body of the test.ts file with response edge function to:
and update the netlify.tomi to
I can see that the edge function is
◈ Loaded edge function hello
up via the--edgeInspect
flag, but when inspected the page I do not see the reponse header. Connecting the debugger doesn't lead to much helpful information that I can see.The text was updated successfully, but these errors were encountered: