forked from cyclic-software/starter-react-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
27 lines (23 loc) · 816 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const express = require('express')
const path = require("path");
const app = express()
// #############################################################################
// This configures static hosting for files in /public that have the extensions
// listed in the array.
var options = {
dotfiles: 'ignore',
etag: false,
extensions: ['htm', 'html','css','js','ico','jpg','jpeg','png','svg'],
index: ['index.html'],
maxAge: '1m',
redirect: false
}
app.use(express.static('build', options))
// Always return the index.html file for any request that doesn't match a static file
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
const port = process.env.PORT || 3000
app.listen(port, () => {
console.log(`React app listening at http://localhost:${port}`)
})