-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·39 lines (23 loc) · 864 Bytes
/
server.js
File metadata and controls
executable file
·39 lines (23 loc) · 864 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
29
30
31
32
33
34
35
36
37
38
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const path = require('path');
var enforce = require('express-sslify');
// require('dotenv').config();
const app = express();
//bodyparser
app.use(bodyParser.json());
enforce.HTTPS({ trustProtoHeader: true })
//DB config
// console.log(process.env.DATABASE);
// const db = require('./config/keys').mongoURI;
//Served compiled static React content in production
if (process.env.NODE_ENV === 'production') {
//serve static files generated by React
app.use(express.static('frontend/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'frontend', 'build', 'index.html'));
});
}
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`Server started on port ${port}`));