Skip to content

Instantly share code, notes, and snippets.

@davekaro
Created November 16, 2015 15:27
Show Gist options
  • Save davekaro/d1b3b8dc3de826e607f2 to your computer and use it in GitHub Desktop.
Save davekaro/d1b3b8dc3de826e607f2 to your computer and use it in GitHub Desktop.
Live reload middleware for ember-cli
# Mostly copied from http://stackoverflow.com/questions/11057905
class LiveReloadMiddleware < Rack::Proxy
def initialize(app)
@app = app
end
def call(env)
# call super if we want to proxy, otherwise just handle regularly via call
(proxy?(env) && super) || @app.call(env)
end
def proxy?(env)
Rack::Request.new(env).path == "/ember-cli-live-reload.js"
end
def rewrite_env(env)
env["HTTP_HOST"] = "localhost:4200"
env
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment