php-proxy icon indicating copy to clipboard operation
php-proxy copied to clipboard

Passes on path

Open czycha opened this issue 7 years ago • 1 comments

Let's say I have this online at http://example.com/proxy and I'm using this to forward to http://api.com/api. When I make a JavaScript fetch request to http://example.com/proxy, the proxy ultimately requests http://api.com/api/proxy, resulting in a 404. Is there some sort of filtering that I should be doing to prevent this path from being appended?

I'm not doing much beyond the example in the readme.

czycha avatar Oct 23 '18 22:10 czycha

I ended up filtering it, overriding the URI that the class passes in:

use GuzzleHttp\Psr7\Uri;

$proxy->filter(function ($request, $response, $next) use ($url) {
	$request = $request->withUri(new Uri($url));
	$response = $next($request, $response);
	return $response;
});

I still think that this is non-standard behavior—it should go to the URL provided by the to function and not modify it to this extent.

czycha avatar Oct 26 '18 13:10 czycha