【发布时间】:2024-01-15 15:53:01
【问题描述】:
我是新手,想开始使用 Node.js。 我尝试运行“Hello, world!”关于群晖:
const http = require('http');
const hostname = '127.0.0.1';
const port = 3001;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
这段代码运行:
~$ node app.js
Server running at http://127.0.0.1:3001/
但访问 Synology 时没有发现任何内容:
ERR_CONNECTION_REFUSED
我找到了说明:
在 Synology 上打开防火墙端口,具体取决于您要运行 xxx 的端口(例如 3001)
或
创建volume1/path_to_your_app/app.js,让http服务器监听8080端口。
此设置在 Synology 上的什么位置?
【问题讨论】: