From 1a0384e820f9577b2ceae785a4c267f1492d8dd1 Mon Sep 17 00:00:00 2001 From: imsyy Date: Mon, 20 Mar 2023 15:50:16 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index cc58ce1..9198329 100644 --- a/app.js +++ b/app.js @@ -31,14 +31,14 @@ app.use(async (ctx, next) => { if (domain === "*") { await next(); } else { - if (ctx.headers.referer !== domain) { - ctx.status = 400; + if (ctx.headers.origin === domain || ctx.headers.referer === domain) { + await next(); + } else { + ctx.status = 403; ctx.body = { - code: 400, + code: 403, message: "请通过正确的域名访问", }; - } else { - await next(); } } });