mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Merge remote-tracking branch 'origin/webui-new' into webui-new
This commit is contained in:
@@ -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-Methods', '*');
|
res.header('Access-Control-Allow-Origin', origin);
|
||||||
res.header('Access-Control-Allow-Headers', '*');
|
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||||
|
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
||||||
res.header('Access-Control-Allow-Credentials', 'true');
|
res.header('Access-Control-Allow-Credentials', 'true');
|
||||||
|
|
||||||
|
if (req.method === 'OPTIONS') {
|
||||||
|
res.sendStatus(204);
|
||||||
|
return;
|
||||||
|
}
|
||||||
next();
|
next();
|
||||||
};
|
};
|
Reference in New Issue
Block a user