Skip to content

Commit

Permalink
feat: cors router
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosantangelo committed Feb 20, 2019
1 parent cad2d14 commit 92bbc07
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/common/ExpressApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 = '') {
Expand Down

0 comments on commit 92bbc07

Please sign in to comment.