Skip to content

Instantly share code, notes, and snippets.

@sergio1990
Last active October 9, 2016 12:50
Show Gist options
  • Save sergio1990/6b0268b442135990407de321a2526fbc to your computer and use it in GitHub Desktop.
Save sergio1990/6b0268b442135990407de321a2526fbc to your computer and use it in GitHub Desktop.
Set SCRIPT_NAME inside Rack middleware
require ::File.expand_path('../config/environment', __FILE__)
class ScriptName
def initialize(app)
@app = app
end
def call(env)
env['SCRIPT_NAME'] += env['HTTP_FRONTEND_URI'].to_s if !Rails.env.development?
@app.call(env)
end
end
use ScriptName
run Rails.application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment