egg使用socket.io时，本地开发时报跨域问题，但是我服务器和前端都配置了跨域为啥还是不行
前端vue.config.js下我这么配置
 devServer: {
    host: "127.0.0.1",
    port: 4002,
    proxy: {
        '/socket.io': {
           target: 'http://127.0.0.1:4001',
            ws: true,
           changeOrigin: true
         },
         'sockjs-node': {
           target: 'http://127.0.0.1:4001',
           ws: false,
          changeOrigin: true
        },
    },

在后端的config.default.js下

 config.middleware = [ 'cors'];
  config.cors = {
    origin: [ 'http://127.0.0.1:4002' ],
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
    credentials: true,
  };

但是运行的时候报错了。报错如下


Access to XMLHttpRequest at 'http://127.0.0.1:4001/socket.io/?EIO=3&transport=polling&t=NRSkOKL' from origin 'http://127.0.0.1:4002' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


救救孩子吧！
