Prefer way to set the base url (setBaseUrl or variable)

Hi Team,

I tried to set my base URL to a variable, but I found there is another way (setBaseUrl ) to set the base URL.

Which is the preferred option to go forward? Any performance cons and pros on those options.

Hi @Gerard.

Setting baseUrl is only possible via the Httpx API. I’m not really sure what do you mean by :thinking::

I’m currently using the Httpx approach and it is working fine enough for me. I don’t believe there is any huge difference in pros and cons because Httpx only wraps up the default k6 http api.

1 Like

Thanks, for the quick response. The project integrates with several third-party components, therefore there is more than one domain used within the script. In that case, I feel defined the base URL and other URLs on global variables and using them within the project is more controllable. I’m sure we can handle multiple URLs’ with httpx option, but the only concern is to import this module otherwise httpx option looks cool.