Spaces:
Sleeping
Sleeping
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(); | |
}; | |
}; | |