From 65ec451e4eac9b8dcfb65186f1019ea34e48db00 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Mon, 19 Oct 2020 19:24:49 -0400 Subject: [PATCH] fix for Report API CORS --- src/api/comm.libraryofcode.org/routes/report.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/comm.libraryofcode.org/routes/report.ts b/src/api/comm.libraryofcode.org/routes/report.ts index 284d725..449bf3e 100644 --- a/src/api/comm.libraryofcode.org/routes/report.ts +++ b/src/api/comm.libraryofcode.org/routes/report.ts @@ -13,6 +13,7 @@ export default class Report extends Route { public bind() { this.router.post('/hard', async (req, res) => { try { + res.setHeader('Access-Control-Allow-Origin', '*'); if (!req.headers.authorization) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED }); if (!req.body.pin || !req.body.userID || !req.body.reason) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.messages.CLIENT_ERROR }); if (req.body.reason?.length < 1) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.codes.CLIENT_ERROR }); @@ -115,6 +116,7 @@ export default class Report extends Route { this.router.post('/v2/soft', async (req, res) => { try { + res.setHeader('Access-Control-Allow-Origin', '*'); if (!req.headers.authorization) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED }); if (!req.body.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.messages.CLIENT_ERROR }); @@ -196,6 +198,7 @@ export default class Report extends Route { this.router.post('/soft', async (req, res) => { try { + res.setHeader('Access-Control-Allow-Origin', '*'); if (!req.headers.authorization) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED }); if (!req.body.pin || !req.body.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR, message: this.constants.messages.CLIENT_ERROR });