Created
June 8, 2012 06:23
-
-
Save balexand/2893933 to your computer and use it in GitHub Desktop.
xip.io request hack
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
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 |
Or you could simply correct the TLD length: https://github.com/fphilipe/xipio/blob/master/lib/xipio/middleware.rb#L8-L9
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or you could use Rack middleware and replace
env['HTTP_HOST']
andenv['SERVER_NAME']
.