【发布时间】:2021-08-20 05:52:12
【问题描述】:
我正在关注this basic tutorial,当我很快发现 socket.io 似乎没有检测到我的 index.html 并且 localhost 给出错误消息 404。所以也许我输入了错误的东西,因此我复制了 the files 来自教程,但同样的问题仍然存在。我错过了什么?
【问题讨论】:
-
仅供参考,该教程没有提供实际加载
index.html的方法,因为该示例中的简单服务器只是一个 socket.io 服务器,并且没有可以服务 index.html 的常规 http 服务器。那么,你是如何加载 index.html 的呢? -
我认为 socket.io 会像 express 一样加载它。
-
没有。 socket.io 只响应 socket.io 请求,而不是常规的网页请求。访问 socket.io 网站,了解如何使用 socket.io WITH Express 的示例,例如 here。
-
我明白了,谢谢。奇怪的是教程怎么缺少...
标签: node.js socket.io localhost http-status-code-404