Closed vieira closed 6 years ago
Thanks for your contribution. However, you should be able to leverage the existing API to do this, since reverse
is just a fallback in case nobody tells hoxy which host to forward to.
let sendHost = 'foo.com';
proxy.intercept('request', req => req.hostname = sendHost);
proxy.intercept({
phase: 'response',
mimeType: 'text/html',
as: '$'
}, (req, resp, cycle) => {
if (resp.$('something') == 'something') {
sendHost = 'www.reddit.com';
}
});
I'd rather not introduce new API surface to Hoxy itself just to support this use case. However, let me know if I haven't understood your use case.
Cheers!
To allow to programmatically control the URL we are reverse proxying after creating an instance of the proxy, use the attribute
this._reverse
instead of the command line opts.reverse.Example Use Case: