Node.js 在路径(http://localhost:3000/path)
我有一个应用程序设置,可以监听Node.js 在路径(http://localhost:3000/path),node.js,express,socket.io,Node.js,Express,Socket.io,我有一个应用程序设置,可以监听localhost:3000 但是我的要求有点不同,因为我必须使用路径http//本地主机:3000/path。当我更新我的server.js文件时,它工作curl localhost:3000/path并且我从index.html得到响应。但无法从socket.io获取响应 比如http//localhost:3000/path/socket.io/?不工作,但http//localhost:3000/socket.io/?有效。尽管我在index.html中定义
localhost:3000
但是我的要求有点不同,因为我必须使用路径<代码>http//本地主机:3000/path。当我更新我的server.js
文件时,它工作curl localhost:3000/path
并且我从index.html
得到响应。但无法从socket.io获取响应
比如http//localhost:3000/path/socket.io/?
不工作,但http//localhost:3000/socket.io/?
有效。尽管我在index.html中定义了这一点:
我通过在server.js中添加var io=path{/app”}
解决了这个问题
if (event == 'continue') {
socket = io.connect('', {
path : "/path/socket.io",
query: "chatID=" + window.name +
"&Authentication=" + sessionStorage.getItem('token') + "&template=" + template + "&AdditionalData=" + additionalD
});
}
else {
socket = io.connect('', {
path : "/path/socket.io",
query: "chatID=" + window.name +
"&Authentication=" + sessionStorage.getItem('Authentication') + "&template=" + template + "&AdditionalData=" + additionalD
});
}