简体   繁体   中英

How to fix Node-express app serving server files through url?

I am facing a problem with my application in live server. My node.js application is serving backend javascript code through url. how to stop serving backend javascript codes from my application. but when I build it on my local machine, it wasn't serving server files.

application root: https://node.shophabb.com .

files serveing problem example: https://node.shophabb.com/index.js

I use app.use(express.static(__dirname + "/public")) to serve static files

I am using a namecheap hosting. I use there (Setup Node.js App) feature.

I guess you put index.js in public folder?

move index.js to root folder and make sure package.json have

"main": "index.js"

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