Skip to content

Commit df8f529

Browse files
committed
routing
1 parent 0c8680f commit df8f529

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

server/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,18 @@ app.use(passport.session());
2424
require('./routes/authRoutes')(app);
2525
require('./routes/billingRoutes')(app);
2626

27+
if (process.env.NODE_ENV === 'production') {
28+
// Express will serve up production assets
29+
// like our main.js file, or main.css file!
30+
app.use(express.static('client/build'));
31+
32+
// Express will serve up the index.html file
33+
// if it doesn't recognize the route
34+
const path = require('path');
35+
app.get('*', (req, res) => {
36+
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
37+
});
38+
}
39+
2740
const PORT = process.env.PORT || 5000;
2841
app.listen(PORT);

0 commit comments

Comments
 (0)