-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathherokuapp.js
More file actions
50 lines (45 loc) · 1.06 KB
/
herokuapp.js
File metadata and controls
50 lines (45 loc) · 1.06 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
const express = require('express');
const app = express();
const path = require('path');
// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist'));
const forceSSL = function() {
return function (req, res, next) {
if (req.headers['x-forwarded-proto'] !== 'https') {
return res.redirect(
['https://', req.get('Host'), req.url].join('')
);
}
next();
}
}
// Instruct the app
// to use the forceSSL
// middleware
app.use(forceSSL());
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname + '/dist/index.html'));
})
// Start the app by listening on the default Heroku port
app.listen(process.env.PORT || 8080);
package.json
{
"name": "rv-social",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"engines": {
"node": "6.11.0",
"npm": "3.10.10"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.2",
"path": "^0.12.7"
}
}