title: XMLHttpRequest cannot load with Socket.io in ExpressJS
body: <p>I am currently using Socket.io npm module running with ExpressJS in my server at port 5555. In my client side, I am using io.connect to my localhost:5555 which is my server inside AngularJS controller. My client side returns XMLHttpRequest continuously. In my server side, I had used </p>
  
  <blockquote>
    <p>app.use(cors())</p>
    
    <p>app.use(cors("<a href="http://localhost:6666" rel="nofollow">http://localhost:6666</a>"))</p>
  </blockquote>
  
  <p>But still no luck.</p>
  
  <p><strong>Client Side</strong> running at localhost:6666</p>
  
  <pre><code>var socket = io.connect("http://localhost:5555");
  </code></pre>
  
  <p><strong>Server Side</strong> running at localhost:5555</p>
  
  <pre><code>var app = express();
  var server = require('http').Server(app);
  var io = require('socket.io')(server);
  var port = process.env.PORT;
  io.set('transports', ['websocket', 'xhr-polling', 'jsonp-polling', 'htmlfile', 'flashsocket']);
  io.set('origins', '*:*');
  </code></pre>
  
  <p>Error Message:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load
    localhost:5555/socket.io/?EIO=3&amp;transport=polling&amp;t=LVsapo4.
    Credentials flag is 'true', but the 'Access-Control-Allow-Credentials'
    header is ''. It must be 'true' to allow credentials. Origin
    'localhost:6666' is therefore not allowed access.</p>
  </blockquote>