From edbe5ef57954eac30be87ab8a4accd0cd9359498 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Mon, 30 Jun 2025 14:47:52 +0800 Subject: [PATCH] 1 --- app/console/controller/ArticleController.php | 5 +++++ app/console/service/ArticleService.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/console/controller/ArticleController.php b/app/console/controller/ArticleController.php index 1ef0de7..277fd08 100644 --- a/app/console/controller/ArticleController.php +++ b/app/console/controller/ArticleController.php @@ -108,6 +108,11 @@ class ArticleController extends BaseController { try { $request->setPost('user_id', $request->user['id']); + + $protocol = $request->header('x-forwarded-proto', + isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'); + $domain = $protocol . '://' . $request->host(); + $request->setPost('domain', $domain); return $this->getService()->add($request->all()) ? $this->successResponse() : $this->errorResponse(); diff --git a/app/console/service/ArticleService.php b/app/console/service/ArticleService.php index 601100d..593e117 100644 --- a/app/console/service/ArticleService.php +++ b/app/console/service/ArticleService.php @@ -78,7 +78,8 @@ class ArticleService extends BaseService // 将OSS直连地址替换为代理地址 $ossDomain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com/'; - $proxyPath = '/console/upload/image/proxy?file='; + $proxyPath = $params['domain'].'/console/upload/image/proxy?file='; + unset($params['domain']); $params['content'] = str_replace( '?Expires=',