For those who see this with the Express backend, there is connect-history-api-fallback middleware , which is implemented as follows.
const express = require('express'); const history = require('connect-history-api-fallback'); const app = express(); app.use(history({ index: '/'
Or with a home node
const http = require('http') const fs = require('fs') const httpPort = 80 http.createServer((req, res) => { fs.readFile('index.htm', 'utf-8', (err, content) => { if (err) { console.log('We cannot open "index.htm" file.') } res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }) res.end(content) }) }).listen(httpPort, () => { console.log('Server listening on: http://localhost:%s', httpPort) })
Both suggestions are in the documentation .
source share