【问题标题】:SockJS multiplexing example 404 index.html not foundSockJS 多路复用示例 404 index.html not found
【发布时间】:2013-04-05 20:26:44
【问题描述】:

看着SockJS multiplex example

我让服务器运行了。当我转到 http://127.0.0.1:9999/multiplex 时,我看到一条欢迎消息“Welcome to SockJS!

当我尝试浏览 index.hmtl http://127.0.0.1:9999/index.html 时,我收到 404 消息“Cannot GET /index.html

index.html”与正在运行的server.js 位于同一目录中。为什么服务器找不到这个文件?

【问题讨论】:

    标签: node.js sockjs


    【解决方案1】:

    请仔细检查您是否使用了良好的快速版本。 Express 3 更改的 API 和代码可能需要一些调整。有关示例,请参见 sockjs-node/examples。

    【讨论】:

    • ran npm list 我的 express 版本是 package.json 文件中指定的 2.5.8。我升级到 express 3.1.1,进行了代码更改,但仍然遇到相同的行为。这是我的服务器的代码 - gist.github.com/dev-e-loper/5332522
    【解决方案2】:

    安装了 express 3.1.1 并制作了一些 code updates to server.js。现在,当我转到http://127.0.0.1:9999/ 时,它为我提供了服务器中指定的 index.html:

    app.get('/', function (req, res) {
        res.sendfile(__dirname + '/index.html');
    });
    

    不知道为什么,但http://127.0.0.1:9999/index.html 仍然没有给我文件。

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 1970-01-01
      • 2015-06-04
      • 2021-11-29
      • 2015-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多