'application/javascript; charset=utf-8']); } // 由安装脚本自身的 src 解析 API 域名,避免把请求 Host 写入可公开缓存的 JavaScript。 $goUrl = '/api/qywx-promotion/go/' . $key; $config = QywxPromotionWidgetService::decode($pool['widget_config_json'] ?? null); $javascript = QywxPromotionWidgetService::renderScript( $key, $goUrl, $config, (int) ($pool['status'] ?? 0) === 1 ); return response($javascript, 200, [ 'Content-Type' => 'application/javascript; charset=utf-8', 'Cache-Control' => 'public, max-age=60', 'X-Content-Type-Options' => 'nosniff', ]); } public function redirect(string $key) { $picked = QywxPromotionRedirectService::pick($key, [ 'source_url' => (string) $this->request->get('from', ''), 'referer' => (string) $this->request->header('referer', ''), 'user_agent' => (string) $this->request->header('user-agent', ''), 'ip' => (string) $this->request->ip(), ]); if (!$picked) { return response('当前暂无可用的企业微信获客助手链接,请稍后再试。', 503, [ 'Content-Type' => 'text/plain; charset=utf-8', 'Cache-Control' => 'no-store', ]); } return redirect($picked['url'], 302)->header([ 'Cache-Control' => 'no-store', 'Referrer-Policy' => 'no-referrer', ]); } }