diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-03-16 19:58:33 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-03-16 19:58:33 -0500 |
| commit | 7704b76f45ce00304fd814e0cd2203a1a8a5e598 (patch) | |
| tree | 880d0b1640a49169f6b11b5786cefeb8106878ac | |
| parent | 97b93d548beff66a5152c95af758ad059fcc7e59 (diff) | |
| download | invidious-7704b76f45ce00304fd814e0cd2203a1a8a5e598.tar.gz invidious-7704b76f45ce00304fd814e0cd2203a1a8a5e598.tar.bz2 invidious-7704b76f45ce00304fd814e0cd2203a1a8a5e598.zip | |
Fix HTTP redirect
| -rw-r--r-- | config/config.yml | 3 | ||||
| -rw-r--r-- | src/helpers.cr | 1 | ||||
| -rw-r--r-- | src/invidious.cr | 15 |
3 files changed, 3 insertions, 16 deletions
diff --git a/config/config.yml b/config/config.yml index 8ff5e990..f8a06faa 100644 --- a/config/config.yml +++ b/config/config.yml @@ -5,5 +5,4 @@ db: password: kemal host: localhost port: 5432 - dbname: invidious -redirect: false
\ No newline at end of file + dbname: invidious
\ No newline at end of file diff --git a/src/helpers.cr b/src/helpers.cr index 5ba9c461..5188cc5d 100644 --- a/src/helpers.cr +++ b/src/helpers.cr @@ -24,7 +24,6 @@ class Config port: Int32, dbname: String, ), - redirect: Bool, dl_api_key: String?, }) end diff --git a/src/invidious.cr b/src/invidious.cr index 9d34f28b..df422b3d 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -27,7 +27,6 @@ CONFIG = Config.from_yaml(File.read("config/config.yml")) pool_size = CONFIG.pool_size threads = CONFIG.threads -redirect = CONFIG.redirect Kemal.config.extra_options do |parser| parser.banner = "Usage: invidious [arguments]" @@ -47,16 +46,6 @@ Kemal.config.extra_options do |parser| exit end end - parser.on("-r REDIRECT", "--redirect=BOOL", "Whether insecure requests should be forced to HTTPS, requires -s (default #{redirect})") do |boolean| - if boolean == "true" - redirect = true - elsif boolean == "false" - redirect = false - else - puts "REDIRECT must be 'true' or 'false'" - exit - end - end end Kemal::CLI.new @@ -537,8 +526,8 @@ error 500 do |env| templated "error" end -# Add redirect if SSL is enabled and redirect is enabled -if Kemal.config.ssl && redirect +# Add redirect if SSL is enabled +if Kemal.config.ssl spawn do server = HTTP::Server.new("0.0.0.0", 80) do |context| redirect_url = "https://#{context.request.host}#{context.request.path}" |
