Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set host from environment variable in HTTP request node

Tags:

node-red

I have a node-red HTTP Request node. I want to use as url, something like this:

http://SERVER_HOST:SERVER_PORT/

How can I substitute server_host and server_port with their equivalent value from the environment?

I don't want to add another node just to set this url, if possible

I've tried:

${SERVER_HOST}
$(SERVER_HOST)
$env(SERVER_HOST)

${'SERVER_HOST'}
$('SERVER_HOST')
$env('SERVER_HOST')
like image 418
Federico Ponzi Avatar asked Apr 01 '26 07:04

Federico Ponzi


1 Answers

You can only set the whole value from a single environment variable directly in nodes configuration.

So you have 2 options:

  1. Set the whole URL as environment variable e.g. $(SERVER_URL)
  2. Use a function node before hand to assemble the parts and set it as msg.url and then pass that into the HTTP-request node.
like image 90
hardillb Avatar answered Apr 03 '26 12:04

hardillb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!