搜索

首页  >  问答  >  正文

node.js - 请问如何解决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.

漂亮男人漂亮男人2749 天前843

全部回复(1)我来回复

  • 習慣沉默

    習慣沉默2017-05-16 13:31:29

    http://stackoverflow.com/ques...

    回复
    0
  • 取消回复