mirror of
https://github.com/mizanxali/uno-online
synced 2025-12-08 03:03:27 +00:00
Deployment setup
This commit is contained in:
10
server.js
10
server.js
@@ -3,6 +3,7 @@ const socketio = require('socket.io')
|
||||
const http = require('http')
|
||||
const cors = require('cors')
|
||||
const { addUser, removeUser, getUser, getUsersInRoom } = require('./users')
|
||||
const path = require('path')
|
||||
|
||||
const PORT = process.env.PORT || 5000
|
||||
|
||||
@@ -51,6 +52,15 @@ io.on('connection', socket => {
|
||||
})
|
||||
})
|
||||
|
||||
//serve static assets in production
|
||||
if(process.env.NODE_ENV === 'production') {
|
||||
//set static folder
|
||||
app.use(express.static('client/build'))
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'))
|
||||
})
|
||||
}
|
||||
|
||||
server.listen(PORT, () => {
|
||||
console.log(`Server running on port ${PORT}`)
|
||||
})
|
||||
Reference in New Issue
Block a user