-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathserver.js
More file actions
44 lines (35 loc) · 1.12 KB
/
server.js
File metadata and controls
44 lines (35 loc) · 1.12 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
const express = require('express');
const path = require('path');
const helmet = require('helmet');
const app = express();
app.use(helmet());
app.use((req, res, next) => {
res.set({
// 'Cache-Control': 'no-store, no-cache, must-revalidate, proxy-revalidate',
'Cache-Control': 'max-age=604800, public',
'Strict-Transport-Security': 'max-age=31536000; preload',
'X-Frame-Options': 'deny',
'X-XSS-Protection': '1; mode=block'
});
return next();
});
app.use(function(req,res,next) {
if(req.headers["x-forwarded-proto"] == "http") {
res.redirect("https://www.timeally.io" + req.url);
} else {
return next();
}
});
app.use(express.static(__dirname));
app.use(express.static(path.join(__dirname, 'build')));
app.get('/ping', function (req, res) {
return res.send('pong');
});
// app.get("*", function(request, response){
// response.redirect("https://" + request.headers.host + request.url);
// });
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on PORT ${port}`));