[Vuejs]-Deploying Vue file in Express is not working as expected

2👍

Just add this line of code

app.use(express.static(path.join(__dirname, 'public')));
So you code would look like this

const express = require('express');
const path = require('path');

const app = express();
const port = process.env.PORT || 1234;

app.use(express.static(path.join(__dirname, 'public')));

// sendFile will go here
app.get('/', function(req, res) {
  res.sendFile(path.join(__dirname, '/public/index.html'));
});

app.listen(port);
console.log('Server started at http://localhost:' + port);

Leave a comment