Skip to content

Instantly share code, notes, and snippets.

@oscaroceguera
Created May 21, 2018 19:59
Show Gist options
  • Save oscaroceguera/d168c65580967125f7ab56b6ccb92ac5 to your computer and use it in GitHub Desktop.
Save oscaroceguera/d168c65580967125f7ab56b6ccb92ac5 to your computer and use it in GitHub Desktop.
Load static app with react, react-router-4, express
const express = require('express')
const path = require('path')
const app = express()
const port = process.env.PORT || 8000
app.use(express.static(path.join(__dirname, '/public')))
app.get('*', function (req, res) {
res.sendFile(path.resolve(__dirname, 'public', 'index.html'))
})
app.listen(port, () => {
console.log('http://localhost:', port)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment