A memo about netlify-cli. Too lazy to file issues or create pull requests for now.
Looks like it has no ability to read headers
in netlify.toml
and only supports _headers
.
Also, in _headers
, it can't override headers set by root web server
such as content-type
.
This is not same behavior as Netlify service and probably netlify-cli
implementation issue.
// In `src/commands/dev/index.js`
const pathHeaderRules = objectForPath(headerRules, requestURL.pathname)
if (!isEmpty(pathHeaderRules)) {
Object.entries(pathHeaderRules).forEach(([key, val]) => res.setHeader(key, val))
}
res.writeHead(req.proxyOptions.status || proxyRes.statusCode, proxyRes.headers)
It calls writeHead
with proxyRes.headers
, which takes a precedent than headers
set by setHeader
in res
.