Added CORS headers to HTTP Server

This commit is contained in:
Kevin Townsend 2015-12-30 05:20:36 +01:00
parent 1e42e16cc4
commit a4a83e2607

View file

@ -66,7 +66,12 @@ aedes.on('publish', function(packet, client) {
});
var web = http.createServer(function(req, res) {
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
var topic = url.parse(req.url).pathname;
if(topic === '/')