报错信息:

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 }

 

相关文章:

  • 2021-05-18
  • 2021-11-06
  • 2022-02-25
  • 2021-12-23
  • 2021-07-26
猜你喜欢
  • 2022-12-23
  • 2022-01-08
  • 2021-09-19
  • 2021-08-31
  • 2021-09-17
  • 2022-01-14
相关资源
相似解决方案