X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/84a387cf5b6b2f379f4e5b2e46efb7c8f46f561e..refs/pull/3364/head:/app/Http/Request.php diff --git a/app/Http/Request.php b/app/Http/Request.php index bd2761a0b..13892603d 100644 --- a/app/Http/Request.php +++ b/app/Http/Request.php @@ -1,26 +1,43 @@ -getScheme().'://'.$this->getHttpHost(); + if ($appUrl) { + return implode('/', array_slice(explode('/', $appUrl), 0, 3)); } - return $base; + return parent::getSchemeAndHttpHost(); } -} \ No newline at end of file + /** + * Override the default request methods to get the base URL + * to directly use the custom APP_URL, if set. + * The base URL never ends with a / but should start with one if not empty. + * + * @return string + */ + public function getBaseUrl() + { + $appUrl = config('app.url', null); + + if ($appUrl) { + return '/' . rtrim(implode('/', array_slice(explode('/', $appUrl), 3)), '/'); + } + + return parent::getBaseUrl(); + } +}