There was an error while loading. Please reload this page.
1 parent 8fcbffd commit 7960a4cCopy full SHA for 7960a4c
index.js
@@ -9,4 +9,16 @@ app.use(bodyParser.urlencoded({ extended: true }));
9
10
app.use('/api/todos', todoRoutes);
11
12
+if (process.env.NODE_ENV === 'production') {
13
+// Express will serve up production assets
14
+// like our main.js file, or main.css file!
15
+app.use(express.static('client/build'));
16
+
17
+// Express will serve up the index.html file
18
+// if it doesn't recognize the route
19
+const path = require('path');
20
+app.get('*', (req, res) =>
21
+res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
22
+);
23
+}
24
app.listen(port, () => console.log(`Server starts on ${port}...`));
0 commit comments