There are recurring questions related to CORS. But none of the solutions worked for me. I am running my application on OpenShift Cloud. I installed the Kors NPM package as an intermediate layer. This is mistake.
The header "Access-Control-Allow-Origin" contains several values of " http://evil.com/ , *", but only one is allowed. The origin of " http://my-app-name.rhcloud.com " is therefore not allowed.
Server side code
var app = express();
var server = require('http').Server(app);
var io = require('socket.io').listen(server);
var cors = require('cors');
app.use(cors());
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
server.listen(server_port, server_ip_address);
Client Side Code
var socket = io.connect('http://my-app-name.rhcloud.com:8000/',{
'forceNew':true
});
I am using angularjs and Express Framework.
user3673959