繁体   English   中英

为什么 express.js 公用文件夹不能在 inte.net 上运行?

[英]Why is express.js public folder not working over the internet?

我的 app.js 代码在端口 3000 上与节点一起运行,然后通过 Nginx 链接到 go public

const express = require('express')
const app = express()
const port = 3000
app.listen(port, () => {
    console.log(`Listening on port ${port}`)
})
app.use(express.static('public'));

在公共文件夹中,有一个 test.html 文件。 当我尝试使用 http://localhost:3000/test.html 在本地访问此文件时,它有效,但是。 当我放置服务器 IP/测试时,html。 我得到一个 Nginx 404 页面。 请解释!

在我的 Nginx 配置默认文件中,我不得不删除try_files $uri $uri/ =404; 代码行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM