Skip to content

Instantly share code, notes, and snippets.

@balexand
Created June 8, 2012 06:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balexand/2893933 to your computer and use it in GitHub Desktop.
Save balexand/2893933 to your computer and use it in GitHub Desktop.
xip.io request hack
if Rails.env.development?
class XipIoMiddleware
def initialize(app)
@app = app
end
def call(env)
%w{HTTP_HOST SERVER_NAME SERVER_ADDR HTTP_X_FORWARDED_HOST}.each do |key|
env[key] = env[key].sub(/myapp\.\d+\.\d+\.\d+\.\d+\.xip\.io/, "myapp.dev") if env[key].present?
end
@app.call(env)
end
end
MyApp::Application.configure do
config.middleware.insert_before 0, XipIoMiddleware
end
end
@balexand
Copy link
Author

balexand commented Jun 8, 2012

Or you could use Rack middleware and replace env['HTTP_HOST'] and env['SERVER_NAME'].

@fphilipe
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment