From 157283a1cc300b43f899d9265c7e57b4b7e2fb59 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Thu, 24 Dec 2020 14:46:11 -0600 Subject: [PATCH] Move CORS to apply to all routes --- Units.flitter.js | 1 + app/CORSUnit.js | 14 ++++++++++++++ app/IonicUnit.js | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 app/CORSUnit.js diff --git a/Units.flitter.js b/Units.flitter.js index c29ccf5..7258c30 100644 --- a/Units.flitter.js +++ b/Units.flitter.js @@ -31,6 +31,7 @@ const FlitterUnits = { * Custom units that modify or add functionality that needs to be made * available to the middleware-routing-controller stack. */ + 'CORS' : require('./app/CORSUnit'), 'Upload' : require('flitter-upload/UploadUnit'), /* diff --git a/app/CORSUnit.js b/app/CORSUnit.js new file mode 100644 index 0000000..3353ce9 --- /dev/null +++ b/app/CORSUnit.js @@ -0,0 +1,14 @@ +const Unit = require('libflitter/Unit') +const cors = require('cors') + +class CORSUnit extends Unit { + static get name() { + return 'cors' + } + + async go(app) { + app.express.use(cors()) + } +} + +module.exports = exports = CORSUnit diff --git a/app/IonicUnit.js b/app/IonicUnit.js index 2425a2b..2084f27 100644 --- a/app/IonicUnit.js +++ b/app/IonicUnit.js @@ -19,7 +19,7 @@ class IonicUnit extends Unit { } async go(app) { - app.express.use(cors()) + // app.express.use(cors()) app.express.use('/i', [ this.canon.get('middleware::auth:UserOnly'),