diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-03-11 10:24:12 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-03-11 10:24:12 -0500 |
| commit | 31d1315c60e4900e2d98901725ecaebc7dd96f51 (patch) | |
| tree | 4c0184cb86d2e107827e481b39be7d6c3b0d8740 | |
| parent | 6d7ae6f6384212ad5a65edbd7383ac425f5b8bff (diff) | |
| download | invidious-31d1315c60e4900e2d98901725ecaebc7dd96f51.tar.gz invidious-31d1315c60e4900e2d98901725ecaebc7dd96f51.tar.bz2 invidious-31d1315c60e4900e2d98901725ecaebc7dd96f51.zip | |
Fix HSTS header
| -rw-r--r-- | src/invidious.cr | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 9936bd39..139c25ae 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -160,6 +160,10 @@ get "/" do |env| templated "index" end +before_all do |env| + env.response.headers.add("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload") +end + get "/watch" do |env| if env.params.query["v"]? id = env.params.query["v"] @@ -342,12 +346,11 @@ end if Kemal.config.ssl && redirect spawn do 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}" if context.request.query redirect_url += "?#{context.request.query}" end - context.response.headers.add "Location", redirect_url + context.response.headers.add("Location", redirect_url) context.response.status_code = 301 end |
