-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
20 lines (17 loc) · 693 Bytes
/
server.js
File metadata and controls
20 lines (17 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const express = require('express');
const path = require('path');
const port = process.env.PORT || 8080;
const app = express();
// //the __dirname is the current directory from where the script is running
app.use(express.static(path.join(__dirname, 'build')));
// //app.use(express.static('build'));
// //send the user to index html page inspite of the url
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
// //or:
// -app.get('/', function (req, res) {
// +app.get('/*', function (req, res) {
// res.sendFile(path.join(__dirname, 'build', 'index.html'));
// });
app.listen(port, () => console.log("Listening on Port", port));