Class: EmberCli::DevServerProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/ember_cli/dev_server_proxy.rb

Overview

Forwards requests made to an Ember application's mount point to its Vite development server.

Assets referenced by the Ember application itself (rather than by its index.html) are resolved against the document's URL, so they are requested from Rails. Proxying them keeps those references working the same way they do when the application is served out of dist.

Constant Summary collapse

ALLOWED_VERBS =
%w[GET HEAD OPTIONS].freeze
SKIPPED_HEADERS =

Hop-by-hop headers, plus the Content-Encoding header describing a body that Net::HTTP may have decoded already.

%w[
  connection
  content-encoding
  keep-alive
  proxy-authenticate
  proxy-authorization
  te
  trailer
  transfer-encoding
  upgrade
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ DevServerProxy

Returns a new instance of DevServerProxy.



27
28
29
# File 'lib/ember_cli/dev_server_proxy.rb', line 27

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/ember_cli/dev_server_proxy.rb', line 31

def call(env)
  request = Rack::Request.new(env)

  unless ALLOWED_VERBS.include?(request.request_method)
    return method_not_allowed
  end

  rack_response(proxy(request))
end