forked from mmelcot/herokuing
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
32 lines (23 loc) · 795 Bytes
/
index.js
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
// this is the main entry point for your full app
// it serves your frontend & provides access to your API
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const api = require('./api/server');
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use((req, res, next) => {
console.log(req.method + ': ' + req.path);
next();
});
app.use('/', express.static(__dirname + '/client/build/'))
app.get('/', (req, res) => {
res.sendFile(__dirname + '/client/build/index.html');
});
app.use('/api', api);
app.get('*', (req, res) => {
res.sendFile(__dirname + '/client/build/index.html');
});
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`listening at http://localhost:${port}`));