# Refer in node to flows location / Serve files from flows location

**URL:** https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835
**Category:** General
**Created:** [13 November 2023 16:24 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835 "2023-11-13T16:24:02Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![BitEater](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@BitEater](https://discourse.nodered.org/u/BitEater)
#### Post date: [13 November 2023 16:24 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/1 "2023-11-13T16:24:02Z")

</div>

Instead of having my HTML/CSS/JS Files as nodes within my Node Red Flows I want to have them in separate files. My Flows file is versioned in git and it would make sense to have all the other files in git. But I don't see a way to serve HTTP files from the location the flows file is stored (or a sub directory). My flow project should run on Windows as well as on a Raspberry Pi.  
Can any give me a hint?  
Thank you

---

<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: [13 November 2023 16:46 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/2 "2023-11-13T16:46:26Z")

</div>

> [@BitEater](#):
>
> My Flows file is versioned in git and it would make sense to have all the other files in git.

What other files?

> [@BitEater](#):
>
> But I don't see a way to serve HTTP files from the location the flows file is stored

"HTTP files" are _not really_ a thing! You serve data (files) via HTTP.

To serve "data" from Node-RED you typically use the http-in and http-out nodes. If you want the data that is transmitted to be loaded from a file then simply put a `file` node between the http-in and http-out. That file can be anywhere (FS permissions permitting)

For example: [Download a file from node-red using standard nodes (flow) - Node-RED](https://flows.nodered.org/flow/db68bd4934cf46f39e6e453a348bc419)

Alternatively, you can serve files from by [configuring `httpStatic`](https://nodered.org/docs/user-guide/runtime/configuration) - again this can be anywhere (permissions permitting)

* * *

Please try to explain a little clearer

---

<div class="post-metadata">

### Author: ![BitEater](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@BitEater](https://discourse.nodered.org/u/BitEater)
#### Post date: [13 November 2023 18:04 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/3 "2023-11-13T18:04:18Z")

</div>

My problem is that when I try to specify a full path I don't know what to specify since the directory is different on Windows and Pi. Is there a placeholder that can be used like: %FlowsDirectory%/myfiles/style.css ?

---

<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: [13 November 2023 18:07 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/4 "2023-11-13T18:07:46Z")

</div>

And is that using file nodes or static paths in the settings file?

Please be specific

---

<div class="post-metadata">

### Author: ![BitEater](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@BitEater](https://discourse.nodered.org/u/BitEater)
#### Post date: [13 November 2023 18:21 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/5 "2023-11-13T18:21:35Z")

</div>

Sorry for leaving out this information. I would prefer to file nodes approach.

I guess I can't do it in the settings file since this would not switch when switching projects.

---

<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: [13 November 2023 18:32 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/6 "2023-11-13T18:32:18Z")

</div>

Using file nodes defaults to the `.node-red` directory. Therefore to serve a file named `page1.html` you would place that file directly alongside the `flows.json` file and simply put `page1.html` in the file name field.

Have you tried?

---

<div class="post-metadata">

### Author: ![BitEater](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@BitEater](https://discourse.nodered.org/u/BitEater)
#### Post date: [13 November 2023 19:05 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/7 "2023-11-13T19:05:07Z")

</div>

I currently don't remember how it is on the Pi but in Windows the files I refer in the file nodes are expected to be in  
C:\Users\[UserName]\AppData\Roaming\npm\.node-red\  
But the flows file location is here:  
C:\Users\[UserName]\.node-red\projects\[ProjectName]\

---

<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: [13 November 2023 19:22 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/8 "2023-11-13T19:22:03Z")

</div>

Hmmm

I'm speaking from memory but I was certain it would be `C:\Users\[UserName]\.node-red\projects\[ProjectName]\`

I rarely use project mode so that might be the issue.

However, it is possible to construct a full file path name using env vars etc so you can pass the file name into the file node after dynamically constructing a full path that is x-compatible between Linux/windows - one that essentially points to the path relative to the flows file

---

<div class="post-metadata">

### Author: ![BitEater](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@BitEater](https://discourse.nodered.org/u/BitEater)
#### Post date: [13 November 2023 19:49 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/9 "2023-11-13T19:49:52Z")

</div>

Ok, but then I have to configure individual environment variables for each project. Still seems to be the best solution.  
Thank you

---

<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: [13 November 2023 20:07 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/10 "2023-11-13T20:07:01Z")

</div>

Not necessarily. Have you inspected the env vars available OOB?

Try putting this in a function node and trigger it from an inject...

```auto
node.warn({env: process.env})

```

You will need to import `process` on the setup tab.

You might find there is an env var you can use to extrapolate a relative path.

---

<div class="post-metadata">

### Author: ![BitEater](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@BitEater](https://discourse.nodered.org/u/BitEater)
#### Post date: [11 December 2023 14:29 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/11 "2023-12-11T14:29:13Z")

</div>

Meanwhile I refactored my project and don't refer to any paths in my nodes. But now I use the httpStatic option in the setting files. Additionally I use the Nunjucks template nodes and added a  
`nunjucks: { folders: ["..."] }` section to the settings file. Unfortunately also this doesn't make sense in my point of view since it cannot be configured per project. But for now I stick with this.  
Thank you for all of your hints.

---

<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: [9 February 2024 14:29 UTC](https://discourse.nodered.org/t/refer-in-node-to-flows-location-serve-files-from-flows-location/82835/12 "2024-02-09T14:29:15Z")

</div>

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