diff --git a/app/common/controller/UsedCarController.php b/app/common/controller/UsedCarController.php index 1d34a63..3e4955d 100644 --- a/app/common/controller/UsedCarController.php +++ b/app/common/controller/UsedCarController.php @@ -395,9 +395,16 @@ class UsedCarController extends BaseController if (!file_exists($publicFile)) { copy($filePath, $publicFile); } + + // 从连接中获取协议(最可靠) + $connection = $request->connection; + $protocol = 'https'; + if ($connection && property_exists($connection, 'transport')) { + $protocol = $connection->transport === 'ssl' ? 'https' : 'http'; + } // 返回访问地址 - $baseUrl = 'http://' . request()->header('host'); + $baseUrl = $protocol.'://' . request()->header('host'); $url = $baseUrl . '/pdf/' . $raw['pdf_src']; return $this->success([