Fix issues with assets and remote host as envvar (PHP_PROXY_REMOTEHOST)
This commit is contained in:
parent
d2d3486414
commit
0d74eaa1eb
17
index.php
17
index.php
|
@ -18,10 +18,15 @@ function sendResponse(Response $response)
|
||||||
http_response_code($response->getStatusCode());
|
http_response_code($response->getStatusCode());
|
||||||
|
|
||||||
foreach ($response->getHeaders() as $header => $values) {
|
foreach ($response->getHeaders() as $header => $values) {
|
||||||
header(sprintf('%s: %s'."\n", $header, implode(', ', $values)));
|
if (strtolower($header) === 'content-type') {
|
||||||
|
header(sprintf('%s: %s', $header, implode('; ', $values)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $response->getBody();
|
$body = $response->getBody();
|
||||||
|
echo $body;
|
||||||
|
|
||||||
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +37,7 @@ function sendResponse(Response $response)
|
||||||
*
|
*
|
||||||
* @return \GuzzleHttp\Psr7\Response
|
* @return \GuzzleHttp\Psr7\Response
|
||||||
*/
|
*/
|
||||||
function doRequest(ServerRequest $request, Client $client)
|
function doRequest(ServerRequest $request, Client $client, $host)
|
||||||
{
|
{
|
||||||
$headers = [];
|
$headers = [];
|
||||||
|
|
||||||
|
@ -41,7 +46,8 @@ function doRequest(ServerRequest $request, Client $client)
|
||||||
}
|
}
|
||||||
|
|
||||||
$serverParams = $request->getServerParams();
|
$serverParams = $request->getServerParams();
|
||||||
$url = sprintf('https://gitnet.fr%s', $serverParams['PATH_INFO'] ?? $serverParams['REQUEST_URI']);
|
$path = !empty($serverParams['PATH_INFO']) ? $serverParams['PATH_INFO'] : $serverParams['REQUEST_URI'];
|
||||||
|
$url = $host.$path;
|
||||||
|
|
||||||
unset($headers['host']);
|
unset($headers['host']);
|
||||||
|
|
||||||
|
@ -58,7 +64,8 @@ function doRequest(ServerRequest $request, Client $client)
|
||||||
try {
|
try {
|
||||||
$apiResponse = doRequest(
|
$apiResponse = doRequest(
|
||||||
ServerRequestFactory::fromGlobals(),
|
ServerRequestFactory::fromGlobals(),
|
||||||
new Client()
|
new Client(),
|
||||||
|
getenv('PHP_PROXY_REMOTEHOST')
|
||||||
);
|
);
|
||||||
} catch (ClientException $e) {
|
} catch (ClientException $e) {
|
||||||
$apiResponse = $e->getResponse();
|
$apiResponse = $e->getResponse();
|
||||||
|
|
Loading…
Reference in a new issue