Search code examples
node-red

Node-RED use of more than one environment variable in an input field


I have a simple problem and I can't figure it out.

I have a subflow in which I have defined 3 environment variables. There I also have a http in node. What I want to do is to set the url field of the node like this: ${some_var}/${other_var} When I use a single environment variable in the URL field it works fine but when I do it like in the example it doesnt work. I have tried many things but cant get it to work. I also searched the internet for about 2 hours now and cant find anything.

Could it be that something like that isn't supported by Node-RED? Is there a way to get this to work?


Solution

  • The documentation on using environment variables within Node-RED is here: https://nodered.org/docs/user-guide/environment-variables (the top search result on google).

    The second sentence says:

    This only works if it replaces the entire property - it cannot be used to substitute just part of the value. For example, it is not possible to use CLIENT-${HOST}.

    As you are inside a subflow, you can define a property of the subflow using the environment variable type - this type does support joining env vars together. You can then use that subflow property as the env var in your node.

    The following screenshot shows how to define an env var called MY_URL.

    enter image description here