Sha256: d73792865977d7e06edf9b0ed6fa388bd74d029f433c49962d2215c4b35a8b33

Contents?: true

Size: 787 Bytes

Versions: 14

Compression:

Stored size: 787 Bytes

Contents

require "rack/proxy"

class Webpacker::DevServerProxy < Rack::Proxy
  def rewrite_response(response)
    _status, headers, _body = response
    headers.delete "transfer-encoding"
    headers.delete "content-length" if Webpacker.dev_server.running? && Webpacker.dev_server.https?
    response
  end

  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["SCRIPT_NAME"] = ""

      super(env)
    else
      @app.call(env)
    end
  end

  private
    def public_output_uri_path
      Webpacker.config.public_output_path.relative_path_from(Webpacker.config.public_path)
    end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
webpacker-jets-3.2.101 lib/webpacker/dev_server_proxy.rb
webpacker-jets-3.2.100 lib/webpacker/dev_server_proxy.rb
webpacker-3.4.3 lib/webpacker/dev_server_proxy.rb
webpacker-4.0.0.pre.pre.2 lib/webpacker/dev_server_proxy.rb
webpacker-4.0.0.pre.pre.1 lib/webpacker/dev_server_proxy.rb
webpacker-3.4.1 lib/webpacker/dev_server_proxy.rb
webpacker-3.4.0 lib/webpacker/dev_server_proxy.rb
webpacker-3.3.1 lib/webpacker/dev_server_proxy.rb
webpacker-3.3.0 lib/webpacker/dev_server_proxy.rb
webpacker-3.2.2 lib/webpacker/dev_server_proxy.rb
webpacker-3.2.1 lib/webpacker/dev_server_proxy.rb
webpacker-3.2.0 lib/webpacker/dev_server_proxy.rb
webpacker-3.1.1 lib/webpacker/dev_server_proxy.rb
webpacker-3.1.0 lib/webpacker/dev_server_proxy.rb