Node.js 什么';node-express-socket.io不';你不让我和你联系吗?

Node.js 什么';node-express-socket.io不';你不让我和你联系吗?,node.js,angular,express,Node.js,Angular,Express,我有以下服务器配置: export default class Server { private static _instance: Server; public app: express.Application; public port: number; public io: socketIO.Server; private httpServer: http.Server; private co

我有以下服务器配置:

    export default class Server {
      private static _instance: Server;
    
      public app: express.Application;
      public port: number;
      public io: socketIO.Server;
      private httpServer: http.Server;
    
      private constructor() {
        this.app = express();
        this.port = SERVER_PORT;
        this.httpServer = new http.Server(this.app);
        this.io = require('socket.io')(this.httpServer);
    
        this.listenToSockets();
      }
    
      private listenToSockets() {
        console.log('Listen Conexion - Scokets');
        this.io.on('connection', (socket) => {
          console.log('New Client Listening');
    
          this.io.on('disconnect', function () {
            console.log('user disconnected');
          });
        });
      }
    
      public static get instance() {
        return this._instance || (this._instance = new this());
      }
    
      start(callback: (...args: any[]) => void) {
        this.httpServer.listen(this.port, callback);
      }
    }
这是我的索引

const server = Server.instance;

// BODY PARSER
server.app.use(bodyParser.urlencoded({ extended: true }));
server.app.use(bodyParser.json());

// CORS
server.app.use(cors());

// ROUTES
server.app.use('/', router);

server.start(() => {
  console.log(`Server Running: [PORT: ${server.port}]`);
});
我正在做一项服务,从angular.ts尝试将我和http://lcoalhost:5000 地址,但我有以下错误:

http://localhost/:1 访问位于的XMLHttpRequest 'http://localhost:5000/socket.io/?EIO=3&transport=polling&t=NMfoJ58' 源于http://localhost:4200'已被CORS策略阻止: 请求的服务器上不存在“Access Control Allow Origin”标头 资源。zone evergreen.js:2845获取 http://localhost:5000/socket.io/?EIO=3&transport=polling&t=NMfoJ58 net::ERR_失败