-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
31 lines (24 loc) · 820 Bytes
/
client.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
const cors = require("cors")
const dotenv = require("dotenv").config()
var express = require("express")
var history = require("connect-history-api-fallback")
const appHost = process.env.VUE_APP_HOST ? process.env.VUE_APP_HOST : "0.0.0.0"
const appPort = process.env.VUE_APP_PORT ? process.env.VUE_APP_PORT : 8080
var app = express()
app.use(cors())
// Middleware for serving '/dist' directory
const staticFileMiddleware = express.static("dist")
// 1st call for unredirected requests
app.use(staticFileMiddleware)
// Support history api
// this is the HTTP request path not the path on disk
app.use(
history({
index: "/index.html",
})
)
// 2nd call for redirected requests
app.use(staticFileMiddleware)
app.listen(appPort, appHost, function() {
console.log("🦈 Sammy was last seen on port %s!", appPort)
})