I'm leveraging Node-red's dashboard web site (.../ui, which maps to <NR home>/node_modules/node-red-dashboard/dist), to store & load web resources, such as HTML pages, images etc.
When I try to load an HTML file (created from an Excel sheet via 'save as HTML'), it comes up perfectly when I call it as a file (file:///C:/ProgramData/Node-red/...), but when I call it as a web resource (http://localhost:1880/ui/...) it loads with data encoding issues as follows:
Does anyone have a clue what could be the root cause of this?
Sorry for not responding earlier (I was away).
The generated HTML is composed of a main file plus a linked subdirectory with resource files. It is quite complex (over 300 lines just for the main file). Below a few extracts:
Main file:
What does that mean?
Are you loading the file via a file in node & sending it to an endpoint?
Are you loading the file via a file in node & sending it through a template node?
Are you pasting the entire content into a ui-template or template node?
Are you serving the spreadsheet files via a static path?
If you open the browsers developer tools and watch the "Network" tab, do you see any failed GET requests? (i.e. missing resources)
Let me explain.
I'm trying to piggyback the Node-red dashboard and leverage it as a general-purpose web server for showing reports & images.
Here I'm not referring at all to uploading files via Node-red nodes, but rather to loading resources directly from a web browser.
In my system, the Node-red dashboard root is C:/ProgramData/Node-red/node_modules/node-red-dashboard/dist
Now suppose I have an HTML report (converted from Excel) called my_report.htm in the above root folder. In the browser, if I specify the URL file:///C:/ProgramData/Node-red/node_modules/node-red-dashboard/dist/my_report.htm the page comes up perfectly. However, if I call it as http://localhost:1880/ui/my_report.htm it comes up with the encoding errors (but no errors showing in the browser "inspect" console).
Edit your settings.js file and setup the entry httpStatic
Uncomment it (remove the 2 // slashes`)
set it to the path of your static folder e.g. c:/users/YOURNAME/.node-red/static
save settings file
restart node-red
Now you can access http://localhost:1880/my_report.htm without any hacks.
Better still
Give your static path a base like /ui so you can use http://localhost:1880/ui/static/my_report.htm - keeping everything relative (i.e. relative dashboard links of static/my_report.htm will work
Thanks. The HTTP root mapping works perfectly. However, the encoding issue remains as before, while both browser console & network are clear of errors.
Any ideas?