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

【字号: 日期:2022-09-13浏览:39作者:雯心

问题描述

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

问题解答

回答1:

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

相关文章: