From 92bbc0727b00625d6e8ee0b7d9e6008c09fb5c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Sant=C3=A1ngelo?= Date: Wed, 20 Feb 2019 11:05:07 +0100 Subject: [PATCH] feat: cors router --- src/common/ExpressApp.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/ExpressApp.ts b/src/common/ExpressApp.ts index d846d808..06050c31 100644 --- a/src/common/ExpressApp.ts +++ b/src/common/ExpressApp.ts @@ -17,7 +17,7 @@ export class ExpressApp { } useCORS() { - this.app.use(function(_, res, next) { + const cors = function(_: any, res: express.Response, next: Function) { res.setHeader('Access-Control-Allow-Origin', '*') res.setHeader('Access-Control-Request-Method', '*') res.setHeader( @@ -27,7 +27,9 @@ export class ExpressApp { res.setHeader('Access-Control-Allow-Headers', 'Content-Type') next() - }) + } + this.app.use(cors) + this.router.all('*', cors) } useVersion(version: string = '') {