handle OPTIONS method

This commit is contained in:
SrGooglo 2024-04-05 20:50:08 +00:00
parent 92f7f81802
commit 1694813321

View File

@ -26,8 +26,13 @@ export default class Engine {
}) })
}) })
// register body parser
await this.app.use(async (req, res, next) => { await this.app.use(async (req, res, next) => {
res.setHeader("Access-Control-Allow-Headers", "Origin, Content-Type, Authorization")
if (req.method === "OPTIONS") {
return res.status(204).end()
}
if (req.headers["content-type"]) { if (req.headers["content-type"]) {
if (!req.headers["content-type"].startsWith("multipart/form-data")) { if (!req.headers["content-type"].startsWith("multipart/form-data")) {
req.body = await req.urlencoded() req.body = await req.urlencoded()