修复跨域问题
This commit is contained in:
parent
1b9b19d66b
commit
1a0384e820
10
app.js
10
app.js
@ -31,14 +31,14 @@ app.use(async (ctx, next) => {
|
|||||||
if (domain === "*") {
|
if (domain === "*") {
|
||||||
await next();
|
await next();
|
||||||
} else {
|
} else {
|
||||||
if (ctx.headers.referer !== domain) {
|
if (ctx.headers.origin === domain || ctx.headers.referer === domain) {
|
||||||
ctx.status = 400;
|
await next();
|
||||||
|
} else {
|
||||||
|
ctx.status = 403;
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
code: 400,
|
code: 403,
|
||||||
message: "请通过正确的域名访问",
|
message: "请通过正确的域名访问",
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
await next();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user