Spaces:
Sleeping
Sleeping
File size: 531 Bytes
f0953a4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import { Request, Response, NextFunction } from "express";
export const cors = () => {
return (req: Request, res: Response, next: NextFunction) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
res.header("Access-Control-Allow-Headers", "Content-Type, Authorization, Cookie");
res.header("Access-Control-Allow-Credentials", "true");
if (req.method === "OPTIONS") {
return res.sendStatus(200);
}
next();
};
};
|