Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created October 9, 2018 08:40
Show Gist options
  • Save amandeepmittal/67617e47fd09ccab2a39234969c1480e to your computer and use it in GitHub Desktop.
Save amandeepmittal/67617e47fd09ccab2a39234969c1480e to your computer and use it in GitHub Desktop.
// routes/index.js
const router = require('express').Router();
const bookRoutes = require('./books');
const path = require('path');
// API routes
router.use('/api/books', bookRoutes);
// If no API routes are hit, send the React app
router.use(function(req, res) {
res.sendFile(path.join(__dirname, '../client/build/index.html'));
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment