0

I'm trying to setup socket.io to connect to a stream server with a different origin.

The server is a dedicated stream server as part of a larger setup and is based on Express.io:

var express = require('express.io'),
    config  = require('./config'),
    app     = express().http().io();

app.io.set('origin','*:*');

app.all('*', function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type");
  res.header("Access-Control-Allow-Methods", 'GET, PUT, POST, DELETE, HEAD', 'OPTIONS');

  // Tried with and without this header
  res.header('Access-Control-Allow-Credentials', false);

  next();
});

app.io.route('ready', function(req) {
    req.io.emit('talk', {
      message: 'io event from an io route on the server'
    });
});

app.listen(4000, function(){
  console.log('Listening on port ' + config.port);
});

Trying to open a connection it results in the following error:

http://localhost:4000/?EIO=2&transport=polling&t=1407621822859-65. 
A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. 
Origin 'http://localhost:8080' is therefore not allowed access.

How can I set up such a connection?

Thanks!

BarakChamo
  • 3,321
  • 5
  • 30
  • 38

1 Answers1

0

The issue is not exactly fixed but I was able to overcome is by reverting to a regular express.js+socket.io combo.

There header issue seems to quiet down even for Cross-Origin requests with this setup.

BarakChamo
  • 3,321
  • 5
  • 30
  • 38