Update stats.ts

解决api跨域报错问题
This commit is contained in:
S1rius 2025-02-08 18:58:55 +08:00 committed by GitHub
parent bce70c1034
commit 68af480cca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,6 +60,11 @@ export default async (
const { websiteId, compare } = req.query;
// 处理 OPTIONS 请求
if (req.method === 'OPTIONS') {
return res.status(200).end(); // 返回 200 OK 表示允许跨域
}
if (req.method === 'GET') {
if (!(await canViewWebsite(req.auth, websiteId))) {
return unauthorized(res);