mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-17 05:40:35 +00:00
fix
This commit is contained in:
parent
7b3c287137
commit
46254a699a
@ -1,10 +1,16 @@
|
|||||||
import type { RequestHandler } from 'express';
|
import type { RequestHandler } from 'express';
|
||||||
|
|
||||||
// CORS 中间件,跨域用
|
// CORS 中间件,跨域用
|
||||||
export const cors: RequestHandler = (_, res, next) => {
|
export const cors: RequestHandler = (req, res, next) => {
|
||||||
res.header('Access-Control-Allow-Origin', '*');
|
const origin = req.headers.origin || '*';
|
||||||
|
res.header('Access-Control-Allow-Origin', origin);
|
||||||
res.header('Access-Control-Allow-Methods', '*');
|
res.header('Access-Control-Allow-Methods', '*');
|
||||||
res.header('Access-Control-Allow-Headers', '*');
|
res.header('Access-Control-Allow-Headers', '*');
|
||||||
res.header('Access-Control-Allow-Credentials', 'true');
|
res.header('Access-Control-Allow-Credentials', 'true');
|
||||||
|
|
||||||
|
if (req.method === 'OPTIONS') {
|
||||||
|
res.sendStatus(204);
|
||||||
|
return;
|
||||||
|
}
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
Loading…
Reference in New Issue
Block a user