簡體   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