Skip to content

Commit

Permalink
deployment prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
viviannnl committed Sep 17, 2023
1 parent 157aace commit 0c419e2
Show file tree
Hide file tree
Showing 3 changed files with 422 additions and 1 deletion.
8 changes: 8 additions & 0 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path')
const express = require('express')
//const { use } = require('./routes/userRoutes')
const dotenv = require('dotenv').config()
Expand All @@ -14,4 +15,11 @@ app.use('/api/users', require('./routes/userRoutes'))
app.use('/api/habits', require('./routes/habitsRoutes'))
app.use('/api/goals', require('./routes/goalsRoutes'))

// Serve frontend
if (process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname, '../frontend/build')))

app.get('*', (req, res) => res.sendFile(path.resolve(__dirname, '../', 'frontend', 'build', 'index.html')))
}

app.listen(port, () => console.log(`Server started on port ${port}`))
Loading

0 comments on commit 0c419e2

Please sign in to comment.