-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (24 loc) · 779 Bytes
/
Copy pathserver.js
File metadata and controls
30 lines (24 loc) · 779 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
require('dotenv').config();
const path = require('path');
const express = require('express');
const compression = require('compression');
const fs = require('fs');
const port = process.env.RECORD_MANAGER_PROD_SERVER_PORT || 8080;
const host = '0.0.0.0';
const app = express();
if (!fs.existsSync(path.join(__dirname, '/build/index.html'))) {
throw 'Index file is missing!';
}
// Compress served content (e.g. favicon.ico)
app.use(compression());
// app that use dynamic route
app.use(express.static(`${__dirname}/build`));
app.get('*', (request, response) => {
response.sendFile(path.join(__dirname, '/build/index.html'));
});
app.listen(port, host, error => {
if (error) {
console.log(error);
}
console.info('Listening on port %s!', port);
});