From 25b490d7b8d9c745ac01aa7b9e5b1b79d509fde1 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Thu, 19 Jan 2023 16:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20User=20Agent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Module.php | 2 +- app/Providers/AppServiceProvider.php | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Models/Module.php b/app/Models/Module.php index 85e750f..1957e93 100644 --- a/app/Models/Module.php +++ b/app/Models/Module.php @@ -71,7 +71,7 @@ public function remote($func, $requests): array public function http(): PendingRequest { - return Http::module($this->api_token, $this->url)->acceptJson()->timeout(5)->withUserAgent('LAECloud-Client'); + return Http::module($this->api_token, $this->url)->acceptJson()->timeout(5); } private function getResponse(Response $response): array diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1ae9788..2b62619 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -34,13 +34,15 @@ public function boot(): void Http::macro('module', function ($api_token, $url) { // 关闭证书验证 - return Http::withoutVerifying()->withHeaders([ - 'X-Module-Api-Token' => $api_token, - 'Content-Type' => 'application/json', - 'Accept' => 'application/json', - ])->withOptions([ - 'version' => 2, - ])->baseUrl($url); + return Http::baseUrl($url) + ->withUserAgent('LAECloud-Client') + ->withHeaders([ + 'X-Module-Api-Token' => $api_token, + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ])->withOptions([ + 'version' => 2, + ]); });