From efdb2487e48ab4c0102c1b441260ef6f3156984b Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Wed, 14 Oct 2015 12:52:25 -0400 Subject: [PATCH] Add CORS support --- lib/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/index.js b/lib/index.js index fa93386..d77b504 100644 --- a/lib/index.js +++ b/lib/index.js @@ -49,6 +49,13 @@ InsightAPI.prototype.start = function(callback) { }; InsightAPI.prototype.setupRoutes = function(app) { + //Enable CORS + app.use(function(req, res, next) { + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); + next(); + }); + //Block routes var blocks = new BlockController(this.node); app.get('/blocks', blocks.list.bind(blocks));