Added CORS headers to HTTP Server
This commit is contained in:
parent
1e42e16cc4
commit
a4a83e2607
1 changed files with 6 additions and 1 deletions
7
index.js
7
index.js
|
|
@ -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 === '/')
|
||||
|
|
|
|||
Loading…
Reference in a new issue