In short. Netlify custom header rules apply to stored files; functions and upstream services must return their required response headers.
Definition: As of 17 October 2026, Netlify custom headers configured in
_headersornetlify.tomlapply to files served from Netlify's backing store. A function that generates a response must return its required headers in code; the same requirement covers Edge Functions and server-side rendered pages.
Key facts
- Netlify's custom headers documentation excludes function responses and proxied content from static custom header rules.
- The Functions API reference specifies that a web request handler returns a
Responseobject. - The Edge Functions API supports returning a response directly or modifying a downstream response through
context.next(). - Netlify's proxy documentation describes redirect header settings that send headers to the destination website with each request.
How are response headers set in a function?
A response header is a field sent with an HTTP response. Netlify's Functions API reference shows a headers option on a returned Response. That is where a function supplies a content type or another required response header.
The following example adapts the documented Response pattern. Netlify's getting started guide uses netlify/functions/hello.mjs for a JavaScript function and maps it to /hello with an exported configuration:
export default async () => {
return new Response("Hello, world!", {
headers: { "content-type": "text/html" }
});
};
export const config = { path: "/hello" };
The header belongs to the response constructed by this handler. For a streaming response, the Functions API uses a ReadableStream as the response body and also shows headers supplied through the Response options.
What changes for Edge Functions and rendered pages?
Netlify's custom header limitations explicitly include server-side rendered (SSR) pages among URLs handled by functions or Edge Functions. Their required headers therefore belong in the code producing the response.
An Edge Function can also modify a response from a later step in the request chain. The Edge Functions API describes calling context.next(), waiting for the downstream response, and returning a modified response. This provides a place to adjust an existing response in middleware, code that runs around another request handler.
What happens when content is proxied?
A proxy fetches content from another service for the requested URL. Netlify's rewrites and proxies documentation shows a headers map inside a redirect rule:
headers = {X-From = "Netlify"}
That map supplies request headers sent to the destination server. The destination site must supply the required response headers for its content, as Netlify's custom headers documentation explains. Checking the response-generating service is therefore part of investigating a missing header on a proxied URL.
Related terms
- How do I set noindex headers on Netlify?
- How do I target Netlify response headers to a directory?
- X-Robots-Tag
FAQ
Does moving a rule from _headers to netlify.toml cover function responses?
No. Both configuration methods have the same backing-store limitation described in Netlify's custom headers documentation. You must supply the header in the function response.
Where does _headers belong for static files?
Netlify places _headers in the publish directory, the folder containing the finished files it deploys. If you use a build command, the file must reach that deployed folder.
Can an Edge Function return an HTML content type?
Yes. The Edge Functions API gives an example using new Response() with headers: { "content-type": "text/html" }. You can use that response option when constructing the response.
Sources
- Netlify, "Custom headers", 1 December 2025
- Netlify, "Functions API reference", 7 October 2026
- Netlify, "Edge Functions API", 7 October 2026
- Netlify, "Rewrites and proxies", 14 July 2025
- Netlify, "Get started with functions", 31 May 2026
Check how a page reads to answer engines. Open the GEO score analyzer