upgrade koa-route
This commit is contained in:
@ -162,8 +162,9 @@ function localWebServer (options) {
|
||||
if (options.spa) {
|
||||
const send = require('koa-send')
|
||||
debug('SPA', options.spa)
|
||||
app.use(_.all('*', function * () {
|
||||
yield send(this, options.spa, { root: path.resolve(options.static.root) || process.cwd() })
|
||||
app.use(_.all('*', function spa (ctx, route, next) {
|
||||
const root = path.resolve(options.static.root) || process.cwd()
|
||||
return send(ctx, options.spa, { root: root }).then(next)
|
||||
}))
|
||||
}
|
||||
return app
|
||||
|
@ -20,7 +20,7 @@ function proxyRequest (route, app) {
|
||||
changeOrigin: true
|
||||
})
|
||||
|
||||
return function * proxyMiddleware () {
|
||||
return function proxyMiddleware () {
|
||||
const next = arguments[arguments.length - 1]
|
||||
const keys = []
|
||||
route.re = pathToRegexp(route.from, keys)
|
||||
@ -29,7 +29,7 @@ function proxyRequest (route, app) {
|
||||
keys.forEach((key, index) => {
|
||||
const re = RegExp(`:${key.name}`, 'g')
|
||||
route.new = route.new
|
||||
.replace(re, arguments[index] || '')
|
||||
.replace(re, arguments[index + 1] || '')
|
||||
})
|
||||
|
||||
/* test no keys remain in the new path */
|
||||
|
Reference in New Issue
Block a user