bruno icon indicating copy to clipboard operation
bruno copied to clipboard

[Feature] Provide well configured axios instance to pre-/post custom scripts

Open mirkogolze opened this issue 1 year ago • 2 comments

Before running any request a complex logic retrieving proxy and ca-configuration is done out of the global and collection level configuration. When I use axios inside a custom javascript I can't benefit of this nice pre-work configuring axios.

It would be grateful to have a mechanism to benefit of the pre-configured axios instance.

E.g. get the instance via require.

  const axiosinstance = require('axiosintance');

or get access to the instance via bru-Object

  bru.getAxiosInstance();

mirkogolze avatar Jan 09 '24 07:01 mirkogolze

Wouldn't it be better to provide something similar as pm.sendRequest() in Postman. So e.g. bru.sendRequest() and it would be wrapper around Axios request with everything like proxy, certs, ... configured. This would be more stable for example if hypothetically Bruno will be changed in the future and Axios will be internally changed to some other HTTP client then it does not affect thousands of user's collections.

martinsefcik avatar Jan 16 '24 21:01 martinsefcik

Any progress on this? Now we're forced to do something like this in pre/post scripts, which is a bit awkward. Would be much nicer of Bruno automagically configured the bru object with the CA settings from the configuration settings.

const rootca = fs.readFileSync(os.homedir + '/wherever/ROOTCA.pem'); const httpsAgent = new https.Agent({ ca: rootca });

bru.sendRequest({ httpsAgent: httpsAgent, etc... });

roband7 avatar Nov 14 '25 16:11 roband7