Predefined web root

I have developed a dashboard-2 UI node, which sometimes needs to fetch external web resources such as CSS stylesheets or icons, located on the server.

The UI widgets need to have web access to these resources. I know I can configure an httpStatic root in settings.js, but looking for an "out-of-the-box" web root, without forcing additional system-level configuration.

There is a default dashboard web-root (<Node-red user dir>\node_modules\@flowfuse\node-red-dashboard\dist), but (as per web security) it will only allow me to point to "upward" locations (subfolders) which get erased upon every dashboard upgrade.

Currently I am solving this by fetching the resources during initialization of the server node and piggybacking them on the config object (sent to the widgets upon widget initialization). But this is cumbersome and not flexible.

Is there a better way?

Hi @omrid
I don't develop anything for the DB.

But all user contributed Nodes, have access to the resources API.

In the root of your Node, create a folder called resources
anything here can then be fetched via standard HTTP calls.

  • My Node Root
    • package.json
    • resources
      • styles.css
      • logo.png

You then call into these resources like so.

<img src="resources/<Your Package Name>/logo.png">

This is the correct way to provide resources for nodes,
but I don't know if this differs for DB, so I could be wrong

See : Loading extra resources in the editor : Node-RED

1 Like

As always, if you are pushing to the edges of one of the Dashboard implementations, you might find it easier in the long-run to use uibuilder which does not make assumptions or constrain you.

Thank you!
This solves the problem!