Closed filmaj closed 7 years ago
Yes that sounds like what we should be doing. The proxy work is mostly very old and was implemented before the current browser platform as we now know it, hence why it most likely isn't playing nicely.
It looks to me like this bit of code in proxy.js intends to enable following redirect code, but functionally seems to fall short.
I think that bit of code might actually be the root of the issue in phonegap/phonegap-cli#652.
I wonder if we can remove our own implementation of redirect following and use http-proxy
's, and reap the benefits of deleting some code as well as fixing a phonegap-cli issue in one go. Gonna look into it.
Actually, thinking about this more, that should be up to the client to do: the client should handle determining what to do with redirect codes.
I got confused as there is actually a bug in the proxy middleware right now if the response to the proxy request returns a different domain, the middleware builds up a faulty URL (which then breaks client behaviour when trying to follow it).
I will update the issue to reflect that problem instead.
If the request being proxied returns a redirect to a location on a different domain, our proxy middleware mishandles it.
It is because of the use of
targetHost
in the location header listener on the proxy response - it assumes we are staying at the same hostname.