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=',