Fix HSTS header
This commit is contained in:
parent
6d7ae6f638
commit
31d1315c60
|
@ -160,6 +160,10 @@ get "/" do |env|
|
||||||
templated "index"
|
templated "index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before_all do |env|
|
||||||
|
env.response.headers.add("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload")
|
||||||
|
end
|
||||||
|
|
||||||
get "/watch" do |env|
|
get "/watch" do |env|
|
||||||
if env.params.query["v"]?
|
if env.params.query["v"]?
|
||||||
id = env.params.query["v"]
|
id = env.params.query["v"]
|
||||||
|
@ -342,12 +346,11 @@ end
|
||||||
if Kemal.config.ssl && redirect
|
if Kemal.config.ssl && redirect
|
||||||
spawn do
|
spawn do
|
||||||
server = HTTP::Server.new("0.0.0.0", 80) do |context|
|
server = HTTP::Server.new("0.0.0.0", 80) do |context|
|
||||||
context.response.headers.add "Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload"
|
|
||||||
redirect_url = "https://#{context.request.host}#{context.request.path}"
|
redirect_url = "https://#{context.request.host}#{context.request.path}"
|
||||||
if context.request.query
|
if context.request.query
|
||||||
redirect_url += "?#{context.request.query}"
|
redirect_url += "?#{context.request.query}"
|
||||||
end
|
end
|
||||||
context.response.headers.add "Location", redirect_url
|
context.response.headers.add("Location", redirect_url)
|
||||||
context.response.status_code = 301
|
context.response.status_code = 301
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue