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. For example, if the web service uses multiple domains you may want to let your users have access to the one they use.
Base URL example: two types of accounts
This is an example of how to handle two types of accounts - sandbox
and production
.
Add a checkbox in your connection parameters that can be checked when the condition is met:
[
{
"name": "sandbox",
"type": "boolean",
"label": "Sandbox"
},
...
]
Implement a condition in both the connection and the base:
{
"baseUrl": "https://{{if(connection.sandbox,'sandbox.', '')}}yourapi.com/api"
}
All modules and remote procedures can then use hard-coded "url": "/uniqueEndpoint"
Base URL example: two environments
This is an example of how to handle two types of accounts - eu
and us
.
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"
},
...
]
Map the environment in both the connection and the base.
{
"baseUrl": "https://{{connection.environment}}.yourapi.com",
...
}
All modules and remote procedures can then use hard-coded "url": "/uniqueEndpoint"
Last updated