mirror of
https://github.com/imsyy/DailyHotApi.git
synced 2026-01-12 13:14:55 +08:00
修复跨域问题
This commit is contained in:
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user