How to dynamically set API base URL in shopify theme extension without hardcoding while deploying the app?

I have a shopify app with a theme extension in which I am making api calls to my backend. I want the base url of the api to not be hardcoded in the liquid code, but to be specified while deploying the app using some type of env variable/flag/config file or any other method, how do I do this?