node.js - Socket.io + nodejs + https results in connection failure with error message "No 'Access-Control-Allow-Origin' header is predent..." -


so i've been working socket.io , nodejs quite time now, i've never tried use socket.io on secured socket layer.

recently i've been trying work valid certificate. however, everytime try connect socket.io server, following error message appears in chrome console;

xmlhttprequest cannot load domain:12457/socket.io/1/?t=1403871407291. no 'access-control-allow-origin' header present on requested resource. origin 'domain' therefore not allowed access. 

as far can see, domain has in access-control-allow-origin header. i've added specific header https server using following code;

var https           = require ('https'); var fs              = require ('fs'); var options         = {                     key: fs.readfilesync('./cert/private.key'),                     cert: fs.readfilesync('./cert/certificate.crt'),                         //requestcert: true,                     ca: [ fs.readfilesync('./cert/ca.pem'), fs.readfilesync('./cert/sub.class1.server.ca.pem') ]                 };  var server          = https.createserver (options, function (req, res) { res.setheader("access-control-allow-origin", "domain"); res.writehead (200); res.end ("nothing see here :o"); });  var socketio            = require ('socket.io').listen (server);  server.listen (12457); 

when run server access-control-allow-origin added, receive same error. however, when request headers separate request, receive following:

http/1.1 200 ok =>  access-control-allow-origin => domain date => fri, 27 jun 2014 12:18:45 gmt connection => close 

note access-control-allow-origin set time right domain.

i somehow got feeling https server setting headers https server self, not socket.io server. have no clue how fix problem ever, question is;

does knows doing wrong?


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -