请问如何解决socket.io的跨域问题

客户端代码(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.

阅读 22.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题