Socketio解决Access-Control-Allow-Origin跨域问题
(2020-12-26 01:48:59)| 分类: htmlcssjsnodejs |
转:https://www.jianshu.com/p/1c966c74ac26
node.js服务器:
io.set('transports', ['websocket', 'xhr-polling', 'jsonp-polling', 'htmlfile', 'flashsocket']);
io.set('origins', '*:*');
JAVA服务器:
Configuration config = new Configuration();
config.setTransports(Transport.POLLING, Transport.WEBSOCKET);
config.setOrigin(":*:");
客户端:
var socket = io.connect('http://127.0.0.1:8081',{transports:['websocket','xhr-polling','jsonp-polling']});

加载中…