简体   繁体   English

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

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

My app.js code that runs with node on port 3000 which is then linked through Nginx to go public我的 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'));

In the public folder, there is a test.html file.在公共文件夹中,有一个 test.html 文件。 When I try accessing this file locally using http://localhost:3000/test.html, it works, However.当我尝试使用 http://localhost:3000/test.html 在本地访问此文件时,它有效,但是。 when I put the servers IP/test,html.当我放置服务器 IP/测试时,html。 I get an Nginx 404 page.我得到一个 Nginx 404 页面。 Please explain!请解释!

In my Nginx config default file I had to remove the try_files $uri $uri/ =404;在我的 Nginx 配置默认文件中,我不得不删除try_files $uri $uri/ =404; line of code.代码行。

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

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