UNPKG

generator-premiere-mern-stack

Version:

A fully function MERN stack generator running on the latest and greatest thats easy to get started with

31 lines (18 loc) 519 B
/* Declare all your client side routes here so that if the user refreshes the page, the server will send * them the HTML file which will allow the react router to then continue handling the request */ import { Router } from 'express'; import { join } from 'path'; const router = Router(); const routes = [ '/', '/subpage' ]; router.get("*", (req, res, next) => { if (routes.includes(req.url)) { res.sendFile(join(__dirname, '../public/index.html')); } else { next(); } }); export default router;