Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit baf6db0

Browse files
authored
fix: re-add express server (#739)
1 parent 5272223 commit baf6db0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

express-server.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const express = require('express')
2+
const fs = require('fs')
3+
const path = require('path')
4+
const history = require('connect-history-api-fallback')
5+
const app = express()
6+
const ip = process.env.EXPLORER_HOST || '127.0.0.1'
7+
const port = process.env.EXPLORER_PORT || 4200
8+
9+
// Web Server
10+
const distPath = path.join(__dirname + '/dist/')
11+
if (fs.existsSync(distPath)) {
12+
const staticFileMiddleware = express.static(distPath)
13+
app.use(staticFileMiddleware)
14+
app.use(history())
15+
app.use(staticFileMiddleware)
16+
app.get('/', function (req, res) {
17+
res.render(path.join(distPath + '/index.html'))
18+
})
19+
const server = app.listen(port, ip)
20+
} else {
21+
throw new Error('No Dist Path - please build')
22+
}

0 commit comments

Comments
 (0)