Skip to content

Commit

Permalink
Use correct protocol (#1425)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Systho authored and gauravtiwari committed Apr 16, 2018
1 parent aa88554 commit acd5d32
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/webpacker/dev_server_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit acd5d32

Please sign in to comment.