3 namespace BookStack\Http;
5 use Illuminate\Http\Request as LaravelRequest;
7 class Request extends LaravelRequest
10 * Override the default request methods to get the scheme and host
11 * to directly use the custom APP_URL, if set.
13 public function getSchemeAndHttpHost(): string
15 $appUrl = config('app.url', null);
18 return implode('/', array_slice(explode('/', $appUrl), 0, 3));
21 return parent::getSchemeAndHttpHost();
25 * Override the default request methods to get the base URL
26 * to directly use the custom APP_URL, if set.
27 * The base URL never ends with a / but should start with one if not empty.
29 public function getBaseUrl(): string
31 $appUrl = config('app.url', null);
34 $parsedBaseUrl = rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/');
36 return empty($parsedBaseUrl) ? '' : ('/' . $parsedBaseUrl);
39 return parent::getBaseUrl();