fixed issue with rewrite 'from' urls containing ports

This commit is contained in:
Lloyd Brookes
2015-11-19 13:40:30 +00:00
parent 36704f264a
commit d486b7a93a
2 changed files with 28 additions and 3 deletions

View File

@ -14,7 +14,7 @@ const pathToRegexp = require('path-to-regexp')
module.exports = localWebServer
/**
* Returns a Koa application you can launch or mix into an existing app.
* Returns a Koa application you can launch or mix into an existing app.
*
* @param [options] {object} - options
* @param [options.static] {object} - koa-static config
@ -190,7 +190,7 @@ function proxyRequest (route, app) {
/* test no keys remain in the new path */
keys.length = 0
pathToRegexp(route.new, keys)
pathToRegexp(url.parse(route.new).path, keys)
if (keys.length) {
this.throw(500, `[PROXY] Invalid target URL: ${route.new}`)
return next()