客戶端程式碼(client.html):
var socket = io.connect('localhost:80');
服務端(server.js):
io = require('socket.io').listen("80",{origins:'*'});
在本機可以正常運行,放到本機伺服器,提示
#XMLHttpRequest cannot load http://localhost/socket.io/?E... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://jess. dev' is therefore not allowed access. The response had HTTP status code 404.
http://stackoverflow.com/ques...