修复跨域问题

This commit is contained in:
imsyy 2023-03-20 15:50:16 +08:00
parent 1b9b19d66b
commit 1a0384e820

10
app.js
View File

@ -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();
}
}
});