From 10b14288cec6eb8516a2e7467a44acc55a4f31de Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Mon, 11 Nov 2024 18:22:54 +0800 Subject: [PATCH] add force scheme --- .env.example | 1 + app/Providers/AppServiceProvider.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index ba7bbc40..05707f5c 100644 --- a/.env.example +++ b/.env.example @@ -92,3 +92,4 @@ CACHE_KEY_AGENT_ALLOW=all_agent_allows CACHE_KEY_AGENT_DENY=all_agent_denies CHANNEL_NAME_SETTING=channel_setting CHANNEL_NAME_MODEL_EVENT=channel_model_event +FORCE_SCHEME= diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1957c680..66bed42f 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -6,6 +6,7 @@ use Carbon\Carbon; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; use Illuminate\Http\Resources\Json\JsonResource; @@ -37,8 +38,11 @@ public function boot() { global $plugin; $plugin->start(); -// JsonResource::withoutWrapping(); DB::connection(config('database.default'))->enableQueryLog(); + $forceScheme = strtolower(env('FORCE_SCHEME')); + if (env('APP_ENV') == "production" && in_array($forceScheme, ['https', 'http'])) { + URL::forceScheme($forceScheme); + } Filament::serving(function () { Filament::registerNavigationGroups([