socket.io不';使用子目录时无法工作

socket.io不';使用子目录时无法工作,socket.io,Socket.io,我刚刚遇到了这个问题。 当我在根目录中使用socket.io时。它工作得很好 app.js index.html 但当我将代码更改为: app.js index.html 它不起作用 有什么帮助吗?谢谢。我想我在这里找到了答案 app.get('/', function (req, res) { res.sendfile(__dirname + '/index.html'); }); var socket = io.connect('http://host.tw:8080/'); so

我刚刚遇到了这个问题。 当我在根目录中使用socket.io时。它工作得很好

app.js index.html 但当我将代码更改为:

app.js index.html 它不起作用


有什么帮助吗?谢谢。

我想我在这里找到了答案
app.get('/', function (req, res) {
    res.sendfile(__dirname + '/index.html');
});
var socket = io.connect('http://host.tw:8080/');
socket.emit('remote:request',{});
app.get('/test', function (req, res) {
    res.sendfile(__dirname + '/index.html');
});
var socket = io.connect('http://host.tw:8080/test');
socket.emit('remote:request',{});