Hi,
How can I access environment variables which are being passed to Node red docker container via. shell script, in the HTML file of a custom node. In HTML file I need to make Ajax calls to get data from API that will be displayed in dropdown as shown below.
I tried $env('API_BASE_URL'), process.env.API_BASE_URL but it doesn't work. Flow and context are unavailable too. Kindly help.
1. Must run NODE-RED with directive settings.js
`node-red --settings {path to settings.js}`
2. Setting variable must correct name
Ex: dbc-custom set for color => dbcCustomColor
If has any variable incorrect name in setting.js => cannot load setting of node
3. Must setting in 2 places:
In settings.js
`dbcCustomColor: true,`
In dbc-custom component
Hello,
The html file code is the code that runs client side and not server side. So not necessarily even on the machine that nodered runs on but instead on the machine with the browser sandboxed in the browser you use to view the editor.
So to use any server side variables in the client side code of the html you would have to create an endpoint in your js file. You than call that endpoint from your html. The endpoint than includes the code to send back the needed information to the nodes edit dialogues html as a response.
This is also how you should retrieve informations from external apis (CORS policy). Create an endpoint in the js and do the request to the external api from there.
An example of how to setup an endpoint and use it can be found for example in the node-red-node-serialport s js: