I'm developing a Rails application that uses an API backend for AJAX requests written with Sinatra.
The API runs separately from Rails:
Rails: localhost:3000
API: localhost:9393
In production, we'll be proxying requests to the API with nginx.
The problem is that we don't have nginx in development mode, we're using thin. So I need some sort of Rack middleware that I can add in development mode to proxy the requests for me.
Can someone give me an example of how to do this?
Perhaps Rack::Proxy:
http://coderack.org/users/cwninja/middlewares/18-rackproxy
use Rack::Proxy do |req|
if req.path =~ %r{identify api request with regex here}
URI.parse("http://localhost:9393/#{req.fullpath}")
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With