mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-02 05:43:40 +08:00
4dce03c0d3
This updates the custom Request handler to provide only the scheme and host on the `getSchemeAndHttpHost` call, instead of providing the whole APP_URL value, while adding an override to the 'getBaseUrl' to use the APP_URL content instead of the guessed/detected Symfony value. Untested apart from simple local setup. Related to #2765
43 lines
950 B
PHP
43 lines
950 B
PHP
<?php
|
|
|
|
namespace BookStack\Http;
|
|
|
|
use Illuminate\Http\Request as LaravelRequest;
|
|
|
|
class Request extends LaravelRequest
|
|
{
|
|
/**
|
|
* Override the default request methods to get the scheme and host
|
|
* to directly use the custom APP_URL, if set.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getSchemeAndHttpHost()
|
|
{
|
|
$appUrl = config('app.url', null);
|
|
|
|
if ($appUrl) {
|
|
return implode('/', array_slice(explode('/', $appUrl), 0, 3));
|
|
}
|
|
|
|
return parent::getSchemeAndHttpHost();
|
|
}
|
|
|
|
/**
|
|
* Override the default request methods to get the base URL
|
|
* to directly use the custom APP_URL, if set.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getBaseUrl()
|
|
{
|
|
$appUrl = config('app.url', null);
|
|
|
|
if ($appUrl) {
|
|
return rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/');
|
|
}
|
|
|
|
return parent::getBaseUrl();
|
|
}
|
|
}
|