RED.nodes.eachConfig is undefined

Hi folks,

I have used RED.nodes.eachConfig already several times, but always in code for sidebars. Now I need to call it from inside the code of a node. Because I need to get the dashboard D2 url, similar to how it is done in the sidebar 'open dashboard' button code.

But RED.nodes.eachConfig it is undefined. I first thought that it is perhaps undefined when my node is being created, so I moved to my onInput handler an lazy load as soon as the first message is being injected:

onInput: function (msg, send, done) {.
    if(!node.dashboardPath) {
        RED.nodes.eachConfig(function (n) {
            if(n.type === 'ui-base') {
                let base = RED.settings.httpNodeRoot || '/'
                let basePart = base.endsWith('/') ? base : `${base}/`
                let dashPart = n.path.startsWith('/') ? n.path.slice(1) : n.path
                node.dashboardPath = `${basePart}${dashPart}`

However while debugging I see eachConfig is still absent in the list:


Not sure if this function is not provided to the nodes for security concerns or another reason? Or if there is perhaps a better way to implement this?


Hi Bart. What is the use case - why do you need the dashboard URL? If this is something other dashboard nodes would want to use, it would make sense for dashboard to expose a helper property or function for easy access.

Morning Steve,

I am finalizing the migration of my old web-push ui node for D2. I will give a typical use case to explain why I need to have the dashboard url in the server side of my node:

  1. Suppose I detect a human on one of my ip cams.
  2. The video footage of that ip cam is accessible via page2 of my dashboard.
  3. I inject a message into my web-push ui node, containing the relative path page2
  4. My node determines the full url for page2 and sends it to the Google (or Microsoft, Apple, ...) push service.
  5. The notification arrives on my Android phone.
  6. I click on the notification
  7. Android will pass it to my browser app (i.e. Chrome)
  8. The browser will call the corresponding service worker js file, i.e. my javascript code that runs in the background.
  9. My service worker js file will call the full url of the dashboard page2.
  10. The Node-RED dashboard will open on page2.

This all happens within a second. So I can navigate very quickly to the dashboard page related to the problem that has triggered the notification.

But that means I need the dashboard url in the server side of my node. And I want to avoid that people need to enter it manually in my config screen. Because when they change it, they will probably forget to change it in my config screen.

Thanks for reading and have a nice day at work :wink:

1 Like

@BartButenaers there may still be a need to enter a base URL (e.g. for when the user of your node is behind a proxy or other kind of gateway) but I understand the use case.


Would it be reasonable to consider adding a hook to the ui-base so that ui contrib nodes can be notified with system info like like this? Alternatively, a callable function in ui-base, ui-page, ui-group whereby the contrib node can request this type of info from its parent?

Seems like it would be useful for tighter integration with DB2 and would remove the need for contrib nodes to jump through ~loops~ hoops to get this?

Open to this for sure - makes sense imo.

I thought I had it already, but in fact, I actually compute it client-side and add it to the setup VueX store. @BartButenaers if you can open an issue detailing what you'd need - then we'll get it in.

Thanks guys!!
I have registered an issue with the details.