forked from mmelcot/herokuing
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (28 loc) · 1018 Bytes
/
Copy pathindex.js
File metadata and controls
38 lines (28 loc) · 1018 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
// 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 path = require('path');
let cookieParser = require('cookie-parser');
//setup express app
let app = express();
app.use(cookieParser());
const api = require('./api/server');
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.use(express.static(path.join(__dirname, '/client/build')));
app.get('*', function (req, res) {
res.sendFile(path.join(__dirname, '/client/build', 'index.html'));
});
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`listening at http://localhost:${port}`));