We’ve just released a way to modify your HTTP response headers in a limited, but useful, fashion.
Essentially, this new features allows you to either add or remove headers via fly.toml
like so:
[[services.ports]]
handlers = ["http"]
port = "80"
# here it is
http_options = { response = { headers = { to-add = "value", to-remove = false } } }
In this case, the to-add: value
would be added to the response headers. The to-remove
header would be removed from the final response our proxy sends to your users.
You can use the new http_options.response.headers
map to:
Add a header
# add the header `my-header: value` to HTTP responses
http_options = { response = { headers = { my-header = "value" } } }
or for multiple-values headers
# depending on the HTTP version, the header output will be different
http_options = { response = { headers = { my-header = ["value1", "value2"] } } }
Remove a header
# remove the `via` header (automatically added by Fly)
http_options = { response = { headers = { via = false } } }