From 684970473ae2e92f17d885735b68e8eb62a07273 Mon Sep 17 00:00:00 2001 From: Tofandel Date: Thu, 13 Jun 2024 23:40:51 +0200 Subject: [PATCH] Support subdomain --- UPGRADE.md | 2 +- src/TwillRoutes.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index bcd263b48a..39d574b1cc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -52,7 +52,7 @@ If you are relying on Quill.js specifics (like css classes), use `'type' => 'qui Previously `withVideo` was true by default, if you relied on this you have to update these media fields to `'withVideo' => true`. -#### SVG's are now no longer passing thorough glide +#### SVG's are now no longer passing through glide These are now rendered directly, you can change this by updating config `twill.glide.original_media_for_extensions` to an empty array `[]` diff --git a/src/TwillRoutes.php b/src/TwillRoutes.php index f72334cd34..9c9624f9b3 100644 --- a/src/TwillRoutes.php +++ b/src/TwillRoutes.php @@ -9,6 +9,8 @@ use Illuminate\Support\Facades\Route; use Illuminate\Support\Str; +use function request; + class TwillRoutes { /** @@ -405,10 +407,14 @@ public function getAuthRedirectPath(): string public function isTwillRequest(): bool { - $adminAppUrl = config('twill.admin_app_url', config('app.url')); + $adminAppUrl = str_replace(['http://', 'https://'], '', config('twill.admin_app_url', config('app.url'))); + $requestHost = request()->getHttpHost(); + + $matchesDomain = config('twill.support_subdomain_admin_routing') ? + Str::startsWith($requestHost, config('twill.admin_app_subdomain', 'admin') . '.') && Str::endsWith($requestHost, '.' . $adminAppUrl) + : !config('twill.admin_app_strict') || $requestHost === $adminAppUrl; - $matchesDomain = !config('twill.admin_app_strict') || Str::endsWith(\request()->getSchemeAndHttpHost(), $adminAppUrl); - $matchesPath = empty(config('twill.admin_app_path')) || \request()->is(config('twill.admin_app_path', '') . '*'); + $matchesPath = empty(config('twill.admin_app_path')) || request()->is(config('twill.admin_app_path', '') . '*'); return $matchesDomain && $matchesPath; }