-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprodServer.jspf.js
More file actions
32 lines (25 loc) · 825 Bytes
/
prodServer.jspf.js
File metadata and controls
32 lines (25 loc) · 825 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
const express = require('express');
const path = require('path');
const port = process.env.PORT || 3000;
const app = express();
// This assumes that all your app files
// `public` directory relative to where your server.js is
app.get('*.js', function (req, res, next) {
req.url = req.url + '.gz';
res.set('Content-Encoding', 'gzip');
res.set('Content-Type', 'text/javascript');
next();
});
app.get('*.css', function (req, res, next) {
req.url = req.url + '.gz';
res.set('Content-Encoding', 'gzip');
res.set('Content-Type', 'text/css');
next();
});
app.use(express.static(__dirname + '/build'));
app.use(express.static(__dirname + '/public'));
app.get('*', function (req, res) {
res.sendFile(path.resolve(__dirname, 'build', 'index.html'));
});
app.listen(port);
console.log('Server started on port ' + port);