diff --git a/bin/worker.js b/bin/worker.js index 4acbf9b..2a9e51a 100644 --- a/bin/worker.js +++ b/bin/worker.js @@ -1,5 +1,7 @@ var path = require('path'); var app = require('express')(); +var bodyParser = require('body-parser'); +var cors = require('cors'); module.exports.run = function(worker) { var httpServer = worker.httpServer; @@ -13,9 +15,12 @@ module.exports.run = function(worker) { app.get('/', function(req, res) { res.render('index', { port: worker.options.port }); }); + + app.use(cors({ methods: 'POST' })); + app.use(bodyParser.json()); app.post('/', function(req, res) { - if (!req.body.data) return res.status(404).end(); - scServer.exchange.publish('log', req.body.data); + if (!req.body) return res.status(404).end(); + scServer.exchange.publish('log', req.body); res.send('OK'); }); diff --git a/package.json b/package.json index d22eb9e..cd39626 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ }, "homepage": "https://github.com/zalmoxisus/remotedev-server", "dependencies": { + "body-parser": "^1.15.0", + "cors": "^2.7.1", "ejs": "^2.4.1", "express": "^4.13.3", "minimist": "^1.2.0",