cors-anywhere icon indicating copy to clipboard operation
cors-anywhere copied to clipboard

Incorrect proxyBaseUrl in case of non root application

Open lerminou opened this issue 8 years ago • 1 comments

I have on my server an Apache application, and I use this nodeJs plugin only to redirect a part of it.

Only the trafic sent to "http://example.com/proxy/[..]" will be routed to the nodeJs application.

To perform this, i create a proxy rule in my apache virtualHost. <Location /proxy> ProxyPass http://127.0.0.1:8081 ProxyPassReverse http://127.0.0.1:8081 </Location>

The variable proxyBaseUrl is set to the host, but in my case, the base is "http://example.com/proxy/" https://github.com/Rob--W/cors-anywhere/blob/143eff177c7e7d4bf241b83c57dd1e2c6378d53b/lib/cors-anywhere.js#L353 So when the remote server sent a redirection, the next call will not have the "/proxy/" path and will not be redirected to the cors plugin. Is it possible to set this baseUrl as an option ?

It works when I made the modification directly to this line.

lerminou avatar Aug 31 '17 13:08 lerminou

I think that a proxyBasePath option that defaults to / would make sense. Then the "/" should be removed here: https://github.com/Rob--W/cors-anywhere/blob/143eff177c7e7d4bf241b83c57dd1e2c6378d53b/lib/cors-anywhere.js#L191

Do you want to submit a PR?

Rob--W avatar Sep 05 '17 10:09 Rob--W