Node.js:HTTPS 服务器上的网关错误(无法获取服务器的文件?)

Node.js:HTTPS 服务器上的网关错误(无法获取服务器的文件?)

因此,我在 render.com 上有一个 Node.js 服务器。它只有 2 个文件(server.js 和 index.html)。但是,当我加载 myservername.onrender.com/index.html 时,对文件 index.html 的请求失败并抛出 502 Bad Gateway。server.js 包含以下内容:

const http = require('http');
const ws = require('ws');
setInterval(()=>{}, 60000);
// Create an HTTP server
const httpSrv = new http.Server(function(req, res){ console.log('request:', req); }); httpSrv.keepAliveTimeout = 3600000; 
httpSrv.listen(443);
const server = new ws.Server({server: httpSrv}); server.keepAliveTimeout = 3600000; // do websocket things

可能是我没有设置服务器的根目录,但我认为那应该是包含启动服务器的脚本的目录,对吧?另外,我在请求回调中只指定了一个日志,所以这可能是问题所在,但我猜服务器应该通过自动发送指定的文件来响应 GET 请求,对吧?我真的不知道问题出在哪里。

相关内容