I have the following proxy for api requests. I want to forward all requests where the past starts with /api to a separate server.
class ApiProxy < Rack::Proxy
def rewrite_env(env)
if Rack::Request.new(env).path =~ %r{^/api}
env['HTTP_HOST'] = ENV['API_PROXIED_HOST']
end
env
end
end
and then in the Rails application.rb
config.middleware.use ApiProxy, streaming: false
This works for http://example.com/api/ping, but I get the following error when trying to access any other url (e.g. http://example.com/test
I have the following proxy for api requests. I want to forward all requests where the past starts with
/api
to a separate server.and then in the Rails application.rb
This works for
http://example.com/api/ping
, but I get the following error when trying to access any other url (e.g.http://example.com/test