Answer the question
In order to leave comments, you need to log in
Heroku local files. Why doesn't app.use(express.static(__dirname + '/public')) work?
Tried about as many options:
1) app.use(express.static(__dirname + '/public')); (only works on LAN)
2) app.use(express.static(path.join(__dirname, 'public'))); (local only)
3) app.use(express.static(process.env.PWD + '/public')); (does not work on heroku)
4) app.use("/public", express.static(__dirname + '/public')); (locally)
None of the options above worked for me on heroku.
package.json:
{
"name": "node-js-getting-started",
"version": "0.0.2",
"description": "Sasa",
"engines": {
"node": "6.11.1"
},
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "node test.js"
},
"dependencies": {
"ejs": "2.5.6",
"express": "^4.15.4",
"socket.io": "^2.0.3"
},
"devDependencies": {
"request": "^2.81.0",
"tape": "^4.7.0"
},
"repository": {
"type": "git",
"url": "https://github.com/heroku/node-js-getting-started"
},
"keywords": [
"node",
"heroku",
"express"
],
"license": "MIT"
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question