[Vuejs]-How to set up VueJS routes and NodeJS Express API routes?

0👍

A one-page website like VueJS handles all the pages client-side. index.html contains all the pages you need configured in your vuejs router. The page shown depends on the url in your address bar.

To fix your code all the request should return a static file from distif it exists and for all other requests return index.html.

app.use(express.static(path.join(__dirname, "../client/dist")));
app.get((req, res) => {
  res.sendFile(path.join(__dirname, "../client/dist", "index.html"));
});

Leave a comment