From 6189e1bce0ff6dd6fad75ae59cab26887f79cc25 Mon Sep 17 00:00:00 2001 From: Systho Date: Thu, 12 Apr 2018 15:55:17 +0200 Subject: [PATCH] Use correct protocol Currently we can run webpacker in either http or https mode. But if we run webpacker in http mode but access it through a reverse proxy handling https, then it will break because the reverse proxy will have set HTTP_X_FORWARDED_PROTO to https and webpack-dev-server will try to understand the request as a secured one. We must override X_FORWARDED_PROTO in the same way as we override the other headers. In the meantime I'm using this initializer as a workaround doing exactly the same work as this PR : ```ruby # config/initializers/webpacker.rb require "webpacker/dev_server_proxy.rb" module Webpacker::DevServerProxy::ProtoOverride def perform_request(env) env["HTTP_X_FORWARDED_PROTO"] = Webpacker.dev_server.protocol super(env) end end Webpacker::DevServerProxy.include Webpacker::DevServerProxy::ProtoOverride ``` --- lib/webpacker/dev_server_proxy.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/webpacker/dev_server_proxy.rb b/lib/webpacker/dev_server_proxy.rb index 04c3c1eee..67f548287 100644 --- a/lib/webpacker/dev_server_proxy.rb +++ b/lib/webpacker/dev_server_proxy.rb @@ -11,6 +11,7 @@ def rewrite_response(response) def perform_request(env) if env["PATH_INFO"].start_with?("/#{public_output_uri_path}") && Webpacker.dev_server.running? env["HTTP_HOST"] = env["HTTP_X_FORWARDED_HOST"] = env["HTTP_X_FORWARDED_SERVER"] = Webpacker.dev_server.host_with_port + env["HTTP_X_FORWARDED_PROTO"] = Webpacker.dev_server.protocol env["SCRIPT_NAME"] = "" super(env)