简体   繁体   中英

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

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. When I try accessing this file locally using http://localhost:3000/test.html, it works, However. when I put the servers IP/test,html. I get an Nginx 404 page. Please explain!

In my Nginx config default file I had to remove the try_files $uri $uri/ =404; line of code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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