-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathserver.js
31 lines (23 loc) · 803 Bytes
/
server.js
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
const express = require('express');
const app = express();
app.use(express.static('./dist'));
app.use((req, res, next) => {
// if (req.headers.host === 'your-app.herokuapp.com')
// return res.redirect(301, 'https://www.your-custom-domain.com');
if (req.headers['x-forwarded-proto'] !== 'https') {
console.log(`upgrading to https req.headers.host`);
return res.redirect('https://' + req.headers.host + req.url);
}
else
return next();
});
app.get('/*', function (req, res) {
res.sendFile('index.html', { root: './dist' }
);
});
app.get('/assets/privacy.html', function(req, res) {
res.sendFile('assets/privacy.html', { root: './dist' }
);
});
app.listen(process.env.PORT || 4200);
console.log(`Running on port ${process.env.PORT || 4200}`)