-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (28 loc) · 1010 Bytes
/
server.js
File metadata and controls
37 lines (28 loc) · 1010 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
26
27
28
29
30
31
32
33
34
35
36
37
//Install express server
const express = require('express');
const bodyParser = require("body-parser"); // added
const path = require('path');
const app = express();
// Parsers
app.use(bodyParser.json()) // added
app.use(bodyParser.urlencoded({ extended: false})); // added
// Serve only the static files form the dist directory
// const distDir = __dirname + '/dist/' // changed
// app.use(express.static(__dirname + '/dist'));
// app.use(express.static(distDir)); // changed
// to this Angular DIST output folder
app.use(express.static(path.join(__dirname, 'dist')));
// not sure about this yet
// API location
// app.use('api', api);
app.get('*', (req, res) => {
res.sendfile(path.join(__dirname, 'dist/index.html'));
});
// replace below with above
// 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, () => {
console.log('server started');
});