bundle install- Copy your
_appoptics_sessioncookie from staging.
Start the server on port 9989
WEBPACK_PORT=4321 SESSION_COOKIE='_appoptics_session=[redacted]; path=/;' bundle exec rackup config.ru -p 9989
| require 'rack-proxy' | |
| abort "WEBPACK_PORT required" unless ENV['WEBPACK_PORT'] | |
| abort "SESSION_COOKIE required" unless ENV['SESSION_COOKIE'] | |
| class ProxyAppoptics < Rack::Proxy | |
| def rewrite_env(env) | |
| env['HTTP_COOKIE'] = ENV['SESSION_COOKIE'] | |
| env | |
| end | |
| def rewrite_response(resp) | |
| status, headers, response = resp | |
| body = response.to_s | |
| .gsub(%r{https://cdn.appoptics.com/assets/(.*)-[A-z0-9]+\.js}, "http://0.0.0.0:#{ENV['WEBPACK_PORT']}/assets/\\1.js") | |
| .gsub('environment: "staging"', 'environment: "dev", instrument: false') | |
| [status, headers, [body]] | |
| end | |
| end | |
| use ProxyAppoptics, {backend: "https://my-stg.appoptics.com"} | |
| run proc {|env| [404, {}, ["not found"]]} |
| source "https://rubygems.org" | |
| gem "rack" | |
| gem "rack-proxy" |