Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在路径(http://localhost:3000/path)_Node.js_Express_Socket.io - Fatal编程技术网

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
                });
            }