How to create a dynamic Base Url without changing resource settings?

Hi I want to change my base url dynamically based on my environment like : dev, qa, stage.

like : http://xxx.dev.xxxxx
in place of dev how can I update it to qa and stage dynamically.

To dynamically change the base URL based on the environment (e.g., dev, qa, stage), you can utilize environment variables or configuration files in your application.

One approach is to define environment-specific variables or configuration files for each environment (dev, qa, stage). For example, you could have separate configuration files named "config.dev.json", "config.qa.json", and "config.stage.json", each containing the respective base URL for the environment.

Then, in your application code, you can load the appropriate configuration file based on the current environment. This can be achieved using build tools, such as Webpack or Parcel, or by using environment-specific scripts to set environment variables dynamically.

By dynamically loading the base URL from the environment-specific configuration, your application will adapt to different environments seamlessly without the need for manual changes.

I hope this helps! Let me know if you have any further questions.

Hey @Rishivendra_Gupta, just to elaborate a bit here. There are a few ways to do this, but most important is understanding what you mean by 'my environment'.

If you are on a plan that allows configuring multiple environments, then that is likely the best way to go. This allows you to set up all your resources with different endpoint, credentials etc based on the environment. Switching the environment in the app changes the queries accordingly.

If you simply want to use the same query in an app but change the URL, setting up a select component with each option is likely the easiest. This will allow you to use the same query and change the endpoint with a component in the app.



CleanShot 2024-04-15 at 10.46.08@2x

Hope this helps!