# Different static files path on nested routes

**URL:** <https://discourse.nodered.org/t/different-static-files-path-on-nested-routes/53294>\
**Category:** General\
**Tags:** http-request\
**Created:** [6 November 2021 13:26 UTC](https://discourse.nodered.org/t/different-static-files-path-on-nested-routes/53294 "2021-11-06T13:26:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VZonys](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@VZonys](https://discourse.nodered.org/u/VZonys)\
**Post date:** [6 November 2021 13:26 UTC](https://discourse.nodered.org/t/different-static-files-path-on-nested-routes/53294/1 "2021-11-06T13:26:30Z")

</div>

Hi, I'm having trouble with static files:  
My problem is:

Then I creating a http-in with route /blog, all static files loading ok [http://localhost:1880/images/posts/post-2-70x70.jpg](http://localhost:1880/images/posts/post-2-70x70.jpg)

But if i add another route like /blog/posts, all static files loads [http://localhost:1880](http://localhost:1880)\*\*/blog/\*\*images/posts/post-2-70x70.jpg

So it adds parent route to the path of static files.  
Any ideas why it happens?

node-red - 2.1.3  
os: win 8.1  
nodejs - 14.18.1

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [6 November 2021 14:16 UTC](https://discourse.nodered.org/t/different-static-files-path-on-nested-routes/53294/2 "2021-11-06T14:16:45Z")

</div>

Hello Vaidas,

with routes `/blog` and `/blog/posts` you are serving an html page?  
how have you configured `httpStatic` in your settings.js file and  
how is the folder structure of the static folder ?  
Can you share an example flow to demonstrate the problem ?

if i had to guess .. the html serving images from `/blog/posts`  
should have a src `../images/posts/<imageName>.jpg`  
`..` to go one level out of the url path ?

---

<div class="post-metadata">

**Author:** ![VZonys](https://avatars.discourse-cdn.com/v4/letter/v/a587f6/32.png) [@VZonys](https://discourse.nodered.org/u/VZonys)\
**Post date:** [6 November 2021 15:01 UTC](https://discourse.nodered.org/t/different-static-files-path-on-nested-routes/53294/3 "2021-11-06T15:01:44Z")

</div>

Hello UnborN,

Yes I'm serving html,  
in settings I use it like this \> httpStatic: path.join(\_\_dirname,"static");  
static folder structure is like this:  
www  
--static  
----images  
------avatars  
------banners  
------etc...  
----vendor  
----js  
----css

Well your example did the trick ../../images/posts/.jpg, I had to go two levels up.

Update:  
I did some research and find this  
Relative Path Summary (applicable to **href, src** etc.,):

```auto
/file_Or_FolderName Root directory
./file_Or_FolderName Current directory
../file_Or_FolderName Previous directory (One level up)
../../file_Or_FolderName Previous of previous directory (Two levels up)
../../../file_Or_FolderName Just like above - Three levels up 

```

so in my case I use /file\_Or\_FolderName. It also works fine and don't have to worry about how deep route can go, always will return to root.

Thanks.

---

<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:** [5 January 2022 15:02 UTC](https://discourse.nodered.org/t/different-static-files-path-on-nested-routes/53294/4 "2022-01-05T15:02:42Z")

</div>

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