-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (21 loc) · 773 Bytes
/
server.js
File metadata and controls
26 lines (21 loc) · 773 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
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const app = express();
const path = require('path');
const api = require('./api/dist');
app.use(bodyParser.json());
app.use('/api', cors(), api.router);
// Routes transitioned to the react app should redirect to the react index.html
app.route('/r/*')
.get((req, res) => {
res.sendFile(path.resolve(path.normalize(__dirname) + '/react_app/build/index.html'));
});
app.use(express.static('dist'));
app.use(express.static('react_app/build'));
// All routes should redirect to the index.html
app.route('/*')
.get((req, res) => {
res.sendFile(path.resolve(path.normalize(__dirname) + '/dist/index.html'));
});
app.listen(process.env.PORT || 9000);