Search code examples
node-red

what is the root directory of my local node-red server?


I'm running a local Node-RED server on my Windows 10 machine to learn the ins and outs. I installed using the default settings, so all of my current pages are running as localhost:1880. The installation root is my local user directory, as in C:\users\myName\.node-red\

I learned that file input and file output nodes see C:\users\myname\ as a relative root.

In a "play" project I need to reference a local .css resource; my flow contains a template node using a Moustache template containing some hard-coded html.

My aim is to insert a

<link rel="stylesheet" href="mystylesheet.css">

into the html head.

Big question is: where do I have to put my stylesheet resource so that the server can find it? Or in other words: what is the root of my local http server? It's obviously not C:\users\myname\ or anything below that.


Solution

  • The File nodes use the current directory of the node-red process as their root - so will depend on how exactly you run it.

    If you want Node-RED to serve content on its http server you can set httpStatic in your settings file to identify a directory to serve content from. We recommend you create a dedicated directory so you don't inadvertently expose other files.