From ccddb84a1956188366dde5cec2855851930e336e Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 17 Jun 2023 09:15:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=A8=E5=9F=9F=E9=97=AE?= =?UTF-8?q?=E9=A2=98:=20#2548?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpSession.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 7896d281..145a08a2 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -594,6 +594,13 @@ void HttpSession::sendResponse(int code, headerOut.emplace("Date", dateStr()); headerOut.emplace("Server", kServerName); headerOut.emplace("Connection", bClose ? "close" : "keep-alive"); + + GET_CONFIG(bool, allow_cross_domains, Http::kAllowCrossDomains); + if (allow_cross_domains) { + headerOut.emplace("Access-Control-Allow-Origin", "*"); + headerOut.emplace("Access-Control-Allow-Credentials", "true"); + } + if (!bClose) { string keepAliveString = "timeout="; keepAliveString += to_string(keepAliveSec);