Commit 810b69a3 authored by Dominic Tarr's avatar Dominic Tarr

[fix] fallback to next middleware if there is no rule.

[doc] add readme
parent d5b34001
......@@ -47,8 +47,9 @@ module.exports = function (urls) {
// If routing to a server on another domain, the hostname in the request must be changed.
req.headers.host = m.host;
// Once any changes are taken care of, this line makes the magic happen.
proxy.proxyRequest(req, res, m.dest);
return proxy.proxyRequest(req, res, m.dest);
}
}
next() //did not have a rule for this request. fall back to next middleware.
}
}
#proxy by url
this is a simple example of a node-http-middleware that will proxy based on the incoming url.
say you want to proxy every request thing under /database to localhost:5984 (couchbd)
(and remove the /database prefix)
this is how:
require('http-proxy').createServer(
require('proxy-by-url')({
'/database': { port: 5984, host: 'localhost' },
})
).listen(8000)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment