forked from hugocxl/markBox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (21 loc) · 837 Bytes
/
app.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
// https://medium.com/@ryanchenkie_40935/angular-cli-deployment-host-your-angular-2-app-on-heroku-3f266f13f352
const express = require('express');
const path = require('path');
const pkg = require('./package.json');
const app = express();
const forceSSL = function () {
return function (req, res, next) {
if (req.headers['x-forwarded-proto'] !== 'https') {
const path = 'https://' + req.get('Host') + req.url;
return res.redirect(path);
}
next();
};
};
app.use(forceSSL());
app.use(express.static(path.join(__dirname, '/dist/markHub-client')));
app.get('/*', function (req, res) {
res.sendFile(path.join(path.join(__dirname, '/dist/markHub-client/index.html')));
});
const port = process.env.PORT || 8080;
app.listen(port, () => console.log(pkg.name + ' ' + pkg.version + ' listening on ' + port));