-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (25 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import repoLink from "../../components/repo-link.js";
export default {
title: "Set HTTP response header",
metaDescription: "Set a custom HTTP response header",
page: function() {
return `
<section>
<h1>Set custom HTTP response headers with an Edge Function</h1>
<p>Use an Edge Function to add HTTP headers to any HTTP response.</p>
<pre><code>import type { Context } from "@netlify/edge-functions";
export default async (request: Request, context: Context) => {
const response = await context.next();
response.headers.set("X-Your-Custom-Header", "A custom value");
return response;
};</code></pre>
<h2>See this in action</h2>
<ul>
<li><a href="/example/set-response-header">This page, without a custom HTTP response header</a></li>
<li><a href="/example/set-response-header?method=set-response-header">This page, but with a custom HTTP response header added</a></li>
<li>${repoLink("set-response-header.ts")}</li>
</ul>
</section>
`;
},
};