Base URL

Base URL is the main URL to a web service, which should be used for every module and remote procedure in an app, e.g. https://mywebservice.com/api/v1.

There might be situations, when you need to have a variable base URL, e.g. if your web service, which you are integrating, uses multiple domains, and you want to let your users to have access to the one they use.

Example 1

Here, is an example of how to handle 2 types of accounts - sandbox and production.

  1. First, add a checkbox in your connection parameters, which can be checked when the condition is met.

[
   {
      "name": "sandbox",
      "type": "boolean",
      "label": "Sandbox"
   },
   ...
]

2. Then, both in the connection and the base, there should be a condition implemented:

{
    "baseUrl": "https://{{if(connection.sandbox,'sandbox.', '')}}yourapi.com/api"
}

3. All modules and remote procedures then can use hard-coded "url": "/uniqueEndpoint".

Example 2

Here, is an example of how to handle 2 types of accounts - eu and us.

  1. First, you need to set up select in your connection parameters, where you let your users choose from available environments:

[
    {
        "name": "environment",
        "type": "select",
        "label": "Environment",
        "options": [
            {
                "label": "EU",
                "value": "eu"
            },
            {
                "label": "US",
                "value": "us"
            }
        ],
        "default": "production"
    },
    ...
]

2. Then, both in the connection and the base, there should be the environment mapped:

{
    "baseUrl": "https://{{connection.environment}}.yourapi.com",
    ...
}

3. All modules and remote procedures then can use hard-coded "url": "/uniqueEndpoint".

Last updated