popomore / koa-proxy

Proxy middleware for koa
223 stars 102 forks source link

Option to exclude url or path #2

Closed mekwall closed 8 years ago

mekwall commented 10 years ago

Would be great if you could pass in an options.exclude so you can proxy everything except an url or path. Maybe allow a string, array or regular expression.

For now, I've worked around this with the following hack:

var proxyMiddleware = proxy({
    host: proxyHost
});
app.use(function* (next) {
    // Do not route anything related to this word
    if (this.path.indexOf(excludedWord) !== -1) {
        return;
    }
    yield* proxyMiddleware.call(this, next);
});
popomore commented 10 years ago

Can you give me a PR?