diff --git a/src/api/comm.libraryofcode.org/routes/report.ts b/src/api/comm.libraryofcode.org/routes/report.ts index 449bf3e..e85dff7 100644 --- a/src/api/comm.libraryofcode.org/routes/report.ts +++ b/src/api/comm.libraryofcode.org/routes/report.ts @@ -11,9 +11,13 @@ export default class Report extends Route { } public bind() { + this.router.all('*', (_req, res, next) => { + res.header('Access-Control-Allow-Origin', '*'); + next(); + }); + 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 }); @@ -116,7 +120,6 @@ 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 }); @@ -198,7 +201,6 @@ 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 });