# Encoding issue in web resources loaded from /ui

**URL:** https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762
**Category:** General
**Created:** [12 July 2023 13:06 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762 "2023-07-12T13:06:06Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [12 July 2023 13:06 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/1 "2023-07-12T13:06:06Z")

</div>

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/](http://localhost:1880/ui/)...**) it loads with data encoding issues as follows:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/fe9008e02814391ab106be97b3013dfa12cb039b.png)

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

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [12 July 2023 15:42 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/2 "2023-07-12T15:42:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [19 July 2023 10:15 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/3 "2023-07-19T10:15:20Z")

</div>

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:

```auto
<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

```auto
<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>

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [19 July 2023 11:14 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/4 "2023-07-19T11:14:37Z")

</div>

> [@omrid](#):
>
> but when I call it as a web resource (**[http://localhost:1880/ui/](http://localhost:1880/ui/)...**) it loads with data encoding issues as follows

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?

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [19 July 2023 11:51 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/5 "2023-07-19T11:51:27Z")

</div>

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](http://localhost:1880/ui/my_report.htm)** it comes up with the encoding errors (but no errors showing in the browser "inspect" console).

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d43ef6587398561c768a577fccb017dfb1ef5940.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/637f865c1f307b6c6ea22446fccff644463371b7.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [19 July 2023 12:04 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/6 "2023-07-19T12:04:18Z")

</div>

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`
  - DOCS: [Configuration : Node-RED](https://nodered.org/docs/user-guide/runtime/configuration#runtime-configuration)

- 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

```auto
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.

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [19 July 2023 12:15 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/7 "2023-07-19T12:15:25Z")

</div>

Thanks, Steve!! Let me try this.

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [23 July 2023 09:51 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/8 "2023-07-23T09:51:32Z")

</div>

> [@Steve-Mcl](#):
>
> #### 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
> 
> ```auto
> httpStatic: [{ path: "c:/users/YOURNAME/.node-red/static" root: "ui/static" }]
> 
> ```

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?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [21 September 2023 09:51 UTC](https://discourse.nodered.org/t/encoding-issue-in-web-resources-loaded-from-ui/79762/9 "2023-09-21T09:51:36Z")

</div>

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