[Vuejs]-Express js blank root page

0👍

The problem why app.use(express.static('dist')); didn’t work was that in index.html I had link to other files like /dist/static/.. what is not correct if my root folder is dist. So, despite moderator set that webpack doesn’t related to this the solution was to change webpack config for production to make build script generate links to file in /dist/index.html like /static/.. instead of /dist/static/..

And obviously I had to change

app.use(express.static('.'));

to

app.use(express.static('dist'));

As a conclusion – it make sense to check generated index.html and analyze if the paths there are correct.

0👍

Sometimes this issue may come because of, the app doesn’t server from the root folder.
For example, /home/user/path-to-the-project” The app need to serve like this.

So here you need to change like below,

app.use(express.static(__dirname + '/dist'));

For more information, you check express doc. See here

Leave a comment