title: socket.io client is giving cros error in ionic application
body: <p>I am trying to implement a chat application using node.js socket.io and ionic 4 but I am getting cros policy error on client side</p>
  
  <p>This is my node.js server</p>
  
  <pre><code>const path = require('path');
  const http = require('http');
  const express = require('express');
  const socketIO = require('socket.io');
  const {Users} = require('./utils/users');
  const publicPath = path.join(__dirname, '../public');
  const port = process.env.PORT || 3000;
  var app = express();
  var server = http.createServer(app);
  var io = socketIO(server);
  var users = new Users();
  app.use(express.static(publicPath));
  app.use( (req, res, next) =&gt; {
    res.header("Access-Control-Allow-Origin", "http://localhost:8100"); //The ionic server
    res.header("Access-Control-Allow-Credentials", "true");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
  });
  io.on('connection', (socket) =&gt; {
    console.log('New user connected', socket.id);
      socket.on('setName', function (data) {
        console.log(data);
        socket.id = data.name;
    });
  </code></pre>
  
  <p>Here is my ionic client I am using ngx-socket-io plugin for socket.io client.</p>
  
  <pre><code>import { Component } from "@angular/core";
  import { Router } from "@angular/router";
  import { NavController } from "@ionic/angular";
  import { Socket } from "ngx-socket-io";
  @Component({
    selector: "app-home",
    templateUrl: "home.page.html",
    styleUrls: ["home.page.scss"]
  })
  export class HomePage {
  
        constructor(
      private router: Router,
      private navCtrl: NavController,
      private api: ApiService,
      private socket: Socket
  
    ) {
         this.socket.connect();
      this.socket.emit("createMessage", "from ionic ");
      }
  }
  </code></pre>
  
  <p>This is my socketIO configuration on app module</p>
  
  <pre><code>import { SocketIoModule, SocketIoConfig } from "ngx-socket-io";
  const config: SocketIoConfig = {
    url: "https://appName.herokuapp.com/",
    options: {}
  };
  
  @NgModule({
    declarations: [AppComponent],
    entryComponents: [],
    imports: [
      BrowserModule,
      ReactiveFormsModule,
      SocketIoModule.forRoot(config),
      IonicStorageModule.forRoot(),
      IonicModule.forRoot(),
  </code></pre>
  
  <p>This is the error I am getting</p>
  
  <pre><code>Access to XMLHttpRequest at 'https://myappName.herokuapp.com/socket.io/?EIO=3&amp;transport=polling&amp;t=MdcwjRC' from origin 'http://localhost:8100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  </code></pre>