Using connect-history-api-fallback' ,but not sure how to implement in vuejs Using connect-history-api-fallback' ,but not sure how to implement in vuejs nginx nginx

Using connect-history-api-fallback' ,but not sure how to implement in vuejs


I think you could do it in 2 ways.

  1. with just nginx (nginx configuration) (For full nginx config check this link)

    location / { try_files $uri $uri/ /index.html;} 
  2. using express like server (server.js file with connect-history-api-fallback)

     const express = require('express'); const history = require('connect-history-api-fallback');const app = express(); app.use(history()); app.use(express.static('src'));app.get('/', (req, res) => {   res.sendFile('src/index.html'); });app.listen(3000, () => console.log('server started'));

--in your router you need to use history mode, follow this vuejs history mode.

Follow this blog for reference https://medium.com/swlh/using-vue-routers-history-mode-6d9395e8122e