-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·25 lines (19 loc) · 802 Bytes
/
server.js
File metadata and controls
executable file
·25 lines (19 loc) · 802 Bytes
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
let express = require('express');
let app = express();
let proxyMiddleware = require('http-proxy-middleware');
// set the port of our application
// process.env.PORT lets the port be set by Heroku
let port = process.env.PORT || 8080;
let target = process.env.API || 'http://localhost:3003/api'
// make express look in the public directory for assets (css/js/img)
app.use(express.static(__dirname + '/dist'));
console.log(target)
app.use('/api/', proxyMiddleware({target: target, changeOrigin: true}))
// set the home page route
app.get('/*', function(req, res) {
// make sure index is in the right directory. In this case /app/index.html
res.sendfile(__dirname +'/dist/index.html');
});
app.listen(port, function() {
console.log('Our app is running on http://localhost:' + port);
});