Created
November 16, 2015 15:27
-
-
Save davekaro/d1b3b8dc3de826e607f2 to your computer and use it in GitHub Desktop.
Live reload middleware for ember-cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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