We’re trying to deploy an app to a staging origin and a production origin. But is there a way to set variables in the origin context?
In the topic linked above it is suggested to use two Connections with hard coded baseURLs. This works, but would require us to duplicate the code/config for the connections AND the webhooks that refer to a connection (since this is configured on the “components”-level in makecomapp.json).
If some variable/label/anything could be picked up from origin config when setting the baseURL in Base/Connection it would be much more convenient.
hmm what about using a condition based on the environment ?
My condition was according to a parameter but you can base your condition according to the connection environment variable.
Look at this example if it makes sense to you:
The fact that webhook1 refers to connection-stage doesn’t seem to matter. It ends up referring to the connection “enabled” in the origin.
We still have to duplicate the connection for this to work - each having a hidden parameter with a default value (but I guess a “common” variable on each would’ve worked too). But at least the duplication stops there.
I still would’ve preferred to see the possibility of defining some variable directly on the origin and just use that but at least we have a working development/deploy flow now.
Why don’t you work with a select parameter as one of your connections parameter? The label can be “Production” or “Staging”, the value however can be the right base url. Then point to this parameter in your base as your baseUrl. I assume all other parameters remain the same.
If not, you can also use “prod” and “stage” (or something similar) as values of the select parameter and use this in your conditions to select the right URL and parameters.
Interesting thoughts.
I was thinking of leveraging git features on my side. Having a main and dev branches with different configurations and merging dev to main whenever I want to release a prod version.
This way you don’t have to duplicate connection, base or universal module.
I created a common variable (in base and connection)
{
"server":"https://myserver.com"
}
and replace the server with {{common.server}} wherever needed.
Then I just need to make sure I don’t crush the common variable (but they don’t even seems to be synchronized with VS Code as it’s supposed to be user for secrets)