From cb0f85e772ab75ac790f7ee345b9acecfe045b75 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Sun, 14 Jan 2018 18:45:02 +0000 Subject: [PATCH] adding some cors to allow silvrtree to get the stuff --- server.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server.js b/server.js index 7d56002..54bbe95 100644 --- a/server.js +++ b/server.js @@ -16,6 +16,12 @@ const cache = apicache.middleware; app.use(express.static(path.join(__dirname, sitePath))); +app.all('/*', function(req, res, next) { + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "X-Requested-With"); + next(); +}); + app.use('/gettrains', cache('60 seconds'), train.getTrainTimes); app.use('/getnexttraintimes', cache('60 seconds'), train.getNextTrainTimes); app.use('/getroute', cache('60 seconds'), train.getRoute);