-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (23 loc) · 788 Bytes
/
server.js
File metadata and controls
28 lines (23 loc) · 788 Bytes
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
28
const express = require('express');
const server = express();
const path = require('path');
const cors = require('cors');
const port = process.env.PORT || 7000;
const mountRoutes = require('./routes');
// require('./_sms')();
server.use(cors());
server.use(express.json());
server.use(express.urlencoded({ extended: true }));
if (process.env.NODE_ENV === 'production') {
server.use(express.static(path.join(__dirname, 'client/build')));
// Anything that doesn't match the above, send back index.html
server.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/client/build/index.html'));
});
} else {
server.use(express.static(path.join(__dirname, 'public')));
}
mountRoutes(server);
server.listen(port, () => {
console.log(`Server running on ${port}`);
});