我想将Strict-Transport-Security标头添加到Web应用程序中。
设置如下
Dispatch = cowboy_router:compile([
{'_', [
{"/", cowboy_static, {file, env_file:filepath({data, "assets/index.html"})}}
]}
]),
{ok, _} = cowboy:start_tls(product_https,
[
{port, 8443},
{certfile, env_file:filepath({etc, "ssl/cert.crt"})},
{keyfile, env_file:filepath({etc, "ssl/key.key"})}
],
#{env => #{dispatch => Dispatch}}
)
在提供静态文件时,在哪里添加HSTS或其他自定义头文件?
1条答案
按热度按时间ca1c2owp1#
Using middleware is the solution.
The setup will be:
And here is the middleware implementation
That will add header aaaaa: bbbbb to all request responses.