title: Missing Access-Control-Allow-Origin header on heroku
body: <p>Some server code at start:</p>
  
  <pre><code>var util = require('util');
  var express = require('express');
  var http = require('http');
  var sio = require('socket.io');
  
  var app = express();
  var server = http.createServer(app);
  var io = sio.listen(server);
  
  console.log('origins-&gt; '+io.origins());
  //io.set("origins","*:*");
  io.origins("*:*");
  
  server.listen(process.env.PORT || 80, function (){
      var addr = server.address();
      console.log('App listening '+JSON.stringify(addr));
  });
  
  app.get('/', function(req, res){
    res.sendFile(__dirname + '/index.html');
  });
  
  io.on('connection', function(socket){
  console.log("user connected");
  
    socket.on('chat message', function(msg){
      io.emit('chat message', msg);
    });
  });
  </code></pre>
  
  <p>Here is git repo: <a href="https://github.com/Foxbond/heroku-socket-test" rel="nofollow">https://github.com/Foxbond/heroku-socket-test</a></p>
  
  <p><strong>{heroku}</strong> means <strong><a href="http://foxclick.heroku.com" rel="nofollow">http://foxclick.heroku.com</a></strong></p>
  
  <p>Error form chrome console:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load {heroku}/socket.io/?EIO=3&amp;transport=polling&amp;t=1416327810844-0. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '{heroku}' is therefore not allowed access. </p>
  </blockquote>
  
  <p>Response headers:</p>
  
  <pre><code>HTTP/1.1 301 Moved Permanently
  Connection: keep-alive
  Server: Cowboy
  Date: Tue, 18 Nov 2014 16:23:34 GMT
  Content-Length: 0
  Location: {heroku}/socket.io/?EIO=3&amp;transport=polling&amp;t=1416327810844-0
  </code></pre>
  
  <p>Everything works on localhost with these response headers:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Content-Type: application/octet-stream
  Content-Length: 101
  Access-Control-Allow-Origin: *
  Set-Cookie: io=cFBQp1g1WCDbE0_1AAAA
  Date: Tue, 18 Nov 2014 16:28:03 GMT
  Connection: keep-alive
  </code></pre>
  
  <p>I have no idea should I do, I think I already tried every possible solution. Thanks for any help!</p>