From 1e2d337854bdb32ce7aa5d4735846a2235311945 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 1 Mar 2026 09:17:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20CLI=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=20request()=20=E4=B8=BA=20null=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 getDetailUrl() 方法中添加 CLI 环境检查 - CLI 环境使用默认域名 uniservice-mobile.hnxinyouhe.com --- backend/app/service/ApprovalService.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/app/service/ApprovalService.php b/backend/app/service/ApprovalService.php index 65c8a22..acc4f24 100644 --- a/backend/app/service/ApprovalService.php +++ b/backend/app/service/ApprovalService.php @@ -565,10 +565,16 @@ class ApprovalService // 如果没有配置,使用当前请求构建 if (!$baseUrl) { - // 检查反向代理的协议头 - $scheme = request()->header('x-forwarded-proto') ?? request()->header('x-scheme') ?? 'https'; - $host = request()->host(); - $baseUrl = $scheme . '://' . $host; + // 检查是否在 CLI 环境 + if (PHP_SAPI === 'cli' || !request()) { + // CLI 环境:使用默认域名 + $baseUrl = 'https://uniservice-mobile.hnxinyouhe.com'; + } else { + // Web 环境:检查反向代理的协议头 + $scheme = request()->header('x-forwarded-proto') ?? request()->header('x-scheme') ?? 'https'; + $host = request()->host(); + $baseUrl = $scheme . '://' . $host; + } } // 统一使用审批详情页,不再跳转到具体业务模块的详情页