From b9fb645bac29a389ac43b7f9aed998fe9b5f8058 Mon Sep 17 00:00:00 2001 From: Ian Webster Date: Sun, 6 Sep 2015 08:20:43 -0700 Subject: [PATCH] Enable CORS so sites can use directly in JS. Fixes #43. --- server/app.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/app.js b/server/app.js index 0f4c50d..cc6c4fa 100644 --- a/server/app.js +++ b/server/app.js @@ -18,6 +18,12 @@ app.use(express.cookieParser()); app.use(express.static(__dirname + '/public')); app.use(express.json()); app.use(express.urlencoded()); +app.use(function(req, res, next) { + // Enable CORS so sites can use the API directly in JS. + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); + next(); +}); // Enable log messages when sending texts. text.debug(true);