From b80b70b1ef8aacf04812f921a8f6ad5f25966c1d Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Sat, 6 May 2023 13:02:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20mock=20api=20?= =?UTF-8?q?=E8=B7=A8=E5=9F=9F=E9=97=AE=E9=A2=98=20(#6797)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/cfc/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mock/cfc/index.js b/mock/cfc/index.js index 50784f165..cda6b5aea 100755 --- a/mock/cfc/index.js +++ b/mock/cfc/index.js @@ -56,7 +56,7 @@ function mockResponse(event, context, callback) { function createHeaders(headers) { let referer = ''; - if (/^(https?\:\/\/[^:\/]+(?:\:\d+)?\/)/i.test(headers['referer'])) { + if (/^(https?\:\/\/[^:\/]+(?:\:\d+)?\/)/i.test(headers['Referer'])) { referer = RegExp.$1.replace(/\/$/, ''); } @@ -64,6 +64,7 @@ function createHeaders(headers) { 'Content-Type': 'Application/json', 'Access-Control-Allow-Headers': 'x-requested-with,content-type', 'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,OPTIONS,HEAD', - 'Access-Control-Allow-Origin': referer ? `${referer}` : '*' + 'Access-Control-Allow-Origin': referer ? `${referer}` : '*', + 'Access-Control-Allow-Credentials': 'true' }; }