Closed fvsch closed 2 months ago
A possible design would be to add a --header
option accepting this format:
servitsy --header '[file_pattern] json_object'
servitsy --header '*.html {"set-cookie": "analytics_consent=0"}'
servitsy --header '{"set-cookie": "analytics_consent=0"}'
and perhaps a shorthand for a single header applying to all files:
servitsy --header 'key:value'
servitsy --header 'set-cookie:analytics_consent=0'
On the JS side, maybe an array like serve
does, but not as verbose:
start({
header: [
{
include: '*',
headers: {'cache-control': 'max-age=300'}
},
{
include: '*.html',
headers: {'set-cookie': 'analytics_consent=0'}
}
]
})
Feature request: https://x.com/hsablonniere/status/1821475701532377471
Prior art:
node-static
package has a--headers
option which accepts a JSON string:serve
package supports aserve.json
configuration files which can define headers with conditions to match specific files: