-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
48 lines (38 loc) · 1.35 KB
/
server.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
Incredibly simple Node.js and Express application server for serving static assets.
Given as an example from the React Router documentation (along with examples
using nginx and Apache):
- https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md#browserhistory
*/
const express = require('express');
const path = require('path');
const port = process.env.PORT || 3535;
const app = express();
const router = express.Router();
app.use(express.static(__dirname + '/docs'));
// app.use(cors)
// about page route (http:https://localhost:8080/about)
router.get('*', function(req, res) {
console.log(path.resolve(__dirname, 'docs/index.html'))
console.log('get me')
res.sendFile(path.resolve(__dirname, 'docs/index.html'));
res.location = req.originalUrl
});
// apply the routes to our application
app.use('/', router);
/*
app.get('/', function(req, res, next) {
console.log(path.resolve(__dirname, 'dist/index.html'))
console.log('get me')
res.sendFile(path.resolve(__dirname, 'dist/index.html'));
res.location = req.originalUrl
})
app.get('*', function(req, res, next) {
console.log(path.resolve(__dirname, 'dist/index.html'))
console.log('get me')
res.sendFile(path.resolve(__dirname, 'dist/index.html'));
res.location = req.originalUrl
})
*/
app.listen(port);
console.log("server started on port http:https://localhost:" + port);