{
/**
* Override the default request methods to get the scheme and host
- * to set the custom APP_URL, if set.
+ * to directly use the custom APP_URL, if set.
*
- * @return \Illuminate\Config\Repository|mixed|string
+ * @return string
*/
public function getSchemeAndHttpHost()
{
- $base = config('app.url', null);
+ $appUrl = config('app.url', null);
- if ($base) {
- $base = trim($base, '/');
- } else {
- $base = $this->getScheme() . '://' . $this->getHttpHost();
+ if ($appUrl) {
+ return implode('/', array_slice(explode('/', $appUrl), 0, 3));
}
- return $base;
+ 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();
}
}