From b167b0bc489769a28f624c5fa84fda8f86602c40 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Tue, 9 Jul 2019 15:12:08 -0400 Subject: [PATCH] Fixed CORS issues --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 579f777..a57fed3 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,13 @@ var db = new sqlite3.Database('./databases/sponsorTimes.db'); // Create an HTTP service. http.createServer(app).listen(80); +//setup CORS correctly +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(); +}); + //add the get function app.get('/api/getVideoSponsorTimes', function (req, res) { let videoID = req.query.videoID;