[Vuejs]-Built Vue SPA not working when using "publicPath"

0๐Ÿ‘

โœ…

I played around with express.static and this combination seems to work for me

const path = require('path');
const express = require('express');
const history = require('connect-history-api-fallback');
const app     = express();

app.use(history());
app.use(express.static(path.join(__dirname, '/dist')));
app.use('/subpath', express.static(path.join(__dirname, '/dist')));

const listener = app.listen(5050, () => {
  console.log(`Open http://localhost:${port} in your browser`);
});

Sidenote : Adding connect-history-api-fallback was not required to solve the initial problem but is required for vue-router to work properly when in history mode.

Leave a comment