报错信息:

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 }

 

内容来源于网络如有侵权请私信删除

文章来源: 博客园

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

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!

相关课程