Encoding issue in web resources loaded from /ui

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:

image

Does anyone have a clue what could be the root cause of this?

What does the html of the page generated by Excel look like, for the section that is failing?

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:

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta name="Excel Workbook Frameset">
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link rel=File-List href="BOM-min_files/filelist.xml">
<title>BIG Data Calc</title>
<![if !supportTabStrip]>
<link id="shLink" href="BOM-min_files/sheet001.htm">

<link id="shLink">

The part that gets corrupted looks like this

<tr height=20 style='height:15.0pt'>
  <td height=20 class=xl72 style='height:15.0pt'>&nbsp;</td>
  <td class=xl91>&nbsp;</td>
  <td class=xl114>Reconciliations per week</td>
  <td class=xl117 width=124 style='border-left:none;width:93pt'><span
  style='mso-spacerun:yes'>        </span>3,000,000,000 </td>
  <td class=xl91>&nbsp;</td>
 </tr>

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)

Do you see any errors in the browsers console?

In short, show us what you are doing?

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).


image

ok, so this is the wrong way to achieve it.

Also, you did not report what you seen in the browsers network tab or console - but I suspect errors due to the hacks.

Better

  • Setup a static directory e.g. c:\users\YOURNAME\.node-red\static
  • Copy your files there
  • 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

This is done by setting httpStatic like this

httpStatic: [ { path: "c:/users/YOURNAME/.node-red/static" root: "ui/static" } ]

Assumptions:

  • c:/users/YOURNAME/.node-red : check and adjust to where your node-red user dir actually is.

Thanks, Steve!! Let me try this.

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?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.