proxy module for test and development activities
npm install axl-mock-proxy
Self generates CA certificates in order to process https requests.
Works out of the box, for custom behaviors like changed core logic - can be extended
Based on mockttp - visit for in-depth doc
``
import MockProxy from "@publishing/node-mock-proxy";
const proxy = new MockProxy("your name used for logs");
// ...processors can be added both before and after proxy is started
proxy.addRequestProcessor(({request, result}) => {
if (request.url.match('stackoverflow.com')){
result.url = request.url.replace('stackoverflow.com', 'you-suck.com')
}
return {request, result};
});
// ...this actually makes it alive - allows connections
await proxy.startProxy(port);
// ...if you don't pass port it will try to find free one. If you pass one that is busy - it will fail
const actualPort = proxy.port;
// ...do your stuff
// ...stop it once you're done
await proxy.stopProxy(); // your processors are cleared here !
// ...done
``