首页 > 其他 > 详细

vue-socket.io跨域问题的解决方法

时间:2020-02-11 14:39:49      阅读:679      评论:0      收藏:0      [点我收藏+]

 

 

报错信息:

1 Access to XMLHttpRequest at ‘http://192.168.37.130:5050/socket.io/?EIO=3&transport=polling&t=N0oqNsW‘ from origin ‘http://localhost:8080‘ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
2 vue-socketio.js?70bb:8 GET http://192.168.37.130:5050/socket.io/?EIO=3&transport=polling&t=N0oqNsW net::ERR_FAILED

解决办法:

 1 //vue.config.js
 2 
 3 module.exports = {
 4   devServer: {
 5     proxy: {
 6         ‘/socket.io‘: {
 7           target: ‘http://192.168.37.130:5050‘,
 8           ws: true,
 9           changeOrigin: true
10         },
11         ‘sockjs-node‘: {
12           target: ‘http://192.168.37.130:5050‘,
13           ws: false,
14           changeOrigin: true
15         },
16     }
17 
18   }
19 }

 

vue-socket.io跨域问题的解决方法

原文:https://www.cnblogs.com/zhengze/p/12294916.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!