-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
85 lines (54 loc) · 1.81 KB
/
Copy pathserver.js
File metadata and controls
85 lines (54 loc) · 1.81 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* Created by sergey on 17.10.15.
*/
'use strict';
var express = require('express');
var path = require('path');
var url = require('url');
var proxy = require('proxy-middleware');
var app = express();
var port = process.env.PORT || 8080;
app.use(function noCacheForRoot(req, res, next) {
if (req.url === '/') {
res.header("Cache-Control", "no-cache, no-store, must-revalidate");
res.header("Pragma", "no-cache");
res.header("Expires", 0);
}
next();
});
app.use('/build/:uid/*', function(req, res, next) {
console.info(req.originalUrl);
var uid = req.params.uid;
path = req.params[0] ? req.params[0] : 'index.html';
res.sendFile(path, {root: './dist'});
});
app.use(express.static(path.join(__dirname, 'dist')));
app.use('/portal', express.static('dist'));
app.use('/healthcheck', function (req, res) {
var data = {};
data['version'] = 1;
data['checks'] = {};
data['status'] = 'pass';
data['notes'] = '';
data['description'] = '';
data['output'] = '';
res.send(data)
});
app.use(express.static(path.join(__dirname, 'dist')));
app.get('/', (request, response) => {
response.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
response.header('Expires', '-1');
response.header('Pragma', 'no-cache');
response.sendFile(path.join(__dirname, 'dist/index.html'));
});
// WARNING ONLY FOR DEV PURPOSE
// var pdfProxyOptions = url.parse('http://0.0.0.0:80');
//
// app.use('/services/pdf', proxy(pdfProxyOptions));
// var proxyOptions = url.parse('https://dev.finmars.com');
// proxyOptions.cookieRewrite = true;
// proxyOptions.headers = {Referer: 'https://dev.finmars.com'};
// app.use('/', proxy(proxyOptions));
app.listen(port, function () {
console.info('Server started at '+port+' port');
});