# httpStatic and projects

**URL:** https://discourse.nodered.org/t/httpstatic-and-projects/62756
**Category:** General
**Tags:** node-red-dashboard
**Created:** [17 May 2022 13:48 UTC](https://discourse.nodered.org/t/httpstatic-and-projects/62756 "2022-05-17T13:48:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![he\_nodered](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@he\_nodered](https://discourse.nodered.org/u/he_nodered)
#### Post date: [17 May 2022 13:48 UTC](https://discourse.nodered.org/t/httpstatic-and-projects/62756/1 "2022-05-17T13:48:34Z")

</div>

Hi,

I manage a few different projects using the very nice git/projects feature. However, I often always add custom visualizations, so I am wondering, if it is possible to define the `httpStatic` parameter in the `settings.js` dynamically?

I think of something like the following in my `settings.js`:

```auto
// settings.js
// ...snip...
module.exports = {
    // ...
    httpStatic: path.join(projectpath, 'static'),
    // ...
}

```

However, I cannot dig out any variable which provides the current `projectpath` for the selected git/project (at least not at the time this file is loaded).

The main idea is to keep the project specific _static_ files alongside the other project files and store them in the git repo, too. This would allow:

- easy switching between different projects (and their visualization/static files) without always additionally changing the `settings.js`
- keeping additional files under version control and in sync with the actual project/flows

I've already looked at the other, similar questions (and some answers), but could not find a simple solution.

Thanks,

Holger

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [17 May 2022 21:24 UTC](https://discourse.nodered.org/t/httpstatic-and-projects/62756/2 "2022-05-17T21:24:14Z")

</div>

> [@he\_nodered](#):
>
> `projectpath`

I _think_ that is always `<userDir>/projects/` though not sure if that helps since there are 2 ways to set the userDir (3 if you count letting node-red do it itself) and I don't think you can retrieve it in settings.js unless you are setting it via an environment variable or not setting it at all.

If not setting the userDir, it will always be in `<userHome>/.node-red/` and you _can_ generally get `userHome` from an OS environment variable (it potentially has different names on different OS's though).

Interesting question though and one that I'd be keen to see some innovative answers to. 🙂

* * *

Ah, of course, the default userDir is found with `path.join(os.homedir(), '.node-red')`, I even have that in my settings.js commented out 😸

If you were using uibuilder and wanted to have project-specific front-end code, you could do:

```auto
...
  uibuilder: {
    uibRoot: path.join(os.homedir(), '.node-red', 'projects', 'uibuilder'),
  },
...

```

---

<div class="post-metadata">

### Author: ![he\_nodered](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@he\_nodered](https://discourse.nodered.org/u/he_nodered)
#### Post date: [18 May 2022 06:23 UTC](https://discourse.nodered.org/t/httpstatic-and-projects/62756/3 "2022-05-18T06:23:43Z")

</div>

Very nice set of hints, thanks!

This would basically help finding the (default) project root folder (as implicit `<userDir>/projects/`), but is still missing the actual project name...

I guess there is no other way as to dig though the sources and find out how the git integration works (and then get the settings/paths from there)...

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [18 May 2022 08:11 UTC](https://discourse.nodered.org/t/httpstatic-and-projects/62756/4 "2022-05-18T08:11:20Z")

</div>

> [@he\_nodered](#):
>
> actual project name

Oops, I must have been tired last night to miss that!

If you are running node-red via systemd, you can have a file containing environment variables to be used. So you could, in theory create a flow that you put in the library and add to each new project that sets an env variable in that file and restarts node-red, that would give you access to it.

---

<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: [17 July 2022 08:11 UTC](https://discourse.nodered.org/t/httpstatic-and-projects/62756/5 "2022-07-17T08:11:36Z")

</div>

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