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