Skip to content

Commit 860403a

Browse files
committed
koa-connect-history-api-fallback
1 parent 6b2b0a8 commit 860403a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

deploy-server/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12+
"koa-connect-history-api-fallback": "^0.3.1",
1213
"http-proxy-middleware": "^0.18.0",
1314
"koa": "^2.5.0",
1415
"koa-send": "^4.1.3",

deploy-server/server.js

+20
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,29 @@ const path = require('path')
33
const Static = require('koa-static')
44
const proxy = require('http-proxy-middleware')
55
const send = require('koa-send')
6+
const history = require('koa-connect-history-api-fallback')
67

78
const app = new Koa()
89

10+
app.use(history({
11+
verbose: true,
12+
disableDotRule: true,
13+
rewrites: [
14+
{
15+
from: /.css$/,
16+
to: function(context) {
17+
return '' + context.parsedUrl.pathname.slice(-17)
18+
}
19+
},
20+
{
21+
from: /.js$/,
22+
to: function(context) {
23+
return '' + context.parsedUrl.pathname.slice(-16)
24+
}
25+
}
26+
]
27+
}))
28+
929
const Public = Static(path.join(__dirname, '../dist'))
1030
app.use(Public)
1131

0 commit comments

Comments
 (0)