使用https在socket.io上阻止跨源请求

时间:2015-02-03 22:38:58

标签: node.js socket.io

我有以下代码服务器端

var app = require('express.io')();
var fs = require('fs');

var options = {
    privateKey : fs.readFileSync(path1).toString(),
    certificate : fs.readFileSync(path2).toString()
};

app.on('connection', function(){});

app.https(options).io();

客户端

var socket = io('https://url:3000', { "secure": true, 'connect timeout': 5000 });

这给了我以下javascript错误

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://url:3000/socket.io/?EIO=3&transport=polling&t=1423002967190-93. This can be fixed by moving the resource to the same domain or enabling CORS.

如何解决这个问题,以便我肯定会使用 https

0 个答案:

没有答案