Mark ingress proxy as trusted in Z-Wave JS app#4597
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughA patch release (1.3.1) that updates the addon manifest version and configures the Z-Wave JS UI service to trust proxy connections by setting the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Home Assistant addon defaults TRUST_PROXY=1 (home-assistant/addons#4597), which covers the largest user group affected by #4535. A redundant UI field would just create two ways to configure the same thing. Reverts: - trustProxy field on GatewayConfig - gateway.trustProxy in managedExternally - Trust Proxy text field in Settings.vue General panel - Trust Proxy entry in docs/usage/setup.md - Settings fallback in configureTrustProxy() Kept (still needed): - parseTrustProxy() coercion — required for TRUST_PROXY=1 to be applied as a hop count rather than the IP literal "1" (the prior env-var path forwarded the raw string to app.set, which Express treats as an IP, leaving trust proxy effectively off). - Removal of the X-Forwarded-For auto-detect middleware (spoofable). - Removal of the blanket xForwardedForHeader validator suppression. Refs #4535 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Z-Wave JS add-on to trust the Home Assistant ingress proxy when running Z-Wave JS UI, addressing validation errors in logs related to proxy configuration.
Changes:
- Export
TRUST_PROXY=1in the add-on service run script so Z-Wave JS UI treats the ingress proxy as trusted. - Bump add-on version from
1.3.0to1.3.1. - Add a
1.3.1changelog entry describing the proxy-related fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
zwave_js/rootfs/etc/services.d/zwave_js/run |
Exports TRUST_PROXY=1 before launching zwave-js-ui. |
zwave_js/config.yaml |
Version bump to 1.3.1. |
zwave_js/CHANGELOG.md |
Adds release note for 1.3.1 describing the proxy validation log fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
## Summary Fixes two issues affecting users behind reverse proxies (notably the Home Assistant addon). ### Socket reconnection loop (Fixes #4564) When the server's auth middleware rejected a socket connection (e.g. expired JWT), the client silently looped on reconnection forever. Socket.IO v4 emits `connect_error` on rejected handshakes, but the client only listened for `error`. - `src/App.vue` — JWT expiry is checked client-side before attempting to connect; an expired token triggers `logout()` instead of a connect attempt. - `src/App.vue` — added a `connect_error` handler. Three consecutive auth failures trigger logout (single failures are tolerated to ride out transient issues); other errors update status to *Reconnecting*. ### `ERR_ERL_UNEXPECTED_X_FORWARDED_FOR` validation error (Fixes #4535) `express-rate-limit` emitted a noisy `ValidationError` on every restart for users running behind a reverse proxy. The pre-existing `TRUST_PROXY` env-var path looked correct but was effectively broken: `TRUST_PROXY=1` was forwarded to `app.set('trust proxy', '1')` as a string, which Express treats as the IP literal `"1"` — leaving trust proxy effectively off and the validation error firing. - `api/app.ts` — `parseTrustProxy()` coerces the raw env value: `"true"`/`"false"` → boolean, numeric strings → hop count integer, anything else → passed through verbatim (IP/CIDR list or preset name). - `api/app.ts` — moved `app.set('trust proxy', ...)` into `startServer()` via `configureTrustProxy()`, mirroring how HTTPS is handled. Logs the resolved value at startup. - `docs/guide/env-vars.md` — expanded the `TRUST_PROXY` description with accepted formats and a note about `ERR_ERL_PERMISSIVE_TRUST_PROXY` (don't set it to `true`; prefer an explicit hop count or IP list). This pairs with home-assistant/addons#4597, which sets `TRUST_PROXY=1` by default in the HA addon — that PR only actually resolves #4535 once this coercion is in place. An earlier revision of this PR added an X-Forwarded-For auto-detect middleware and a UI toggle for trust proxy; both have been dropped. Auto-detect was spoofable (any client could trip it via a forged XFF header and bypass the login rate-limiter), and the UI field became redundant once the HA addon set the env var by default. ## Test plan - [ ] Verify socket connects successfully when running behind HA ingress proxy - [ ] Verify no `ERR_ERL_UNEXPECTED_X_FORWARDED_FOR` errors in logs when behind proxy with `TRUST_PROXY=1` - [ ] Verify expired JWT token triggers logout instead of reconnect loop - [ ] Verify `TRUST_PROXY=1` is applied as a hop count (integer), not as the IP literal `"1"` - [ ] Verify `TRUST_PROXY` accepting an IP/CIDR list still works - [ ] Verify direct connections (no proxy) are unaffected - [ ] `npm run lint` passes --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@agners I figure it would be slightly more correct to pass the actual ingress proxy IP - any clue how I can determine that programmatically? |
…2 → 11.17.0 (#47891) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [docker.io/zwavejs/zwave-js-ui](https://redirect.github.com/zwave-js/zwave-js-ui) | minor | `c43f88e` → `7982788` | --- > [!WARNING] > Some dependencies could not be looked up. Check the [Dependency Dashboard](../issues/18710) for more information. Add the preset `:preserveSemverRanges` to your config if you don't want to pin your dependencies. --- ### Release Notes <details> <summary>zwave-js/zwave-js-ui (docker.io/zwavejs/zwave-js-ui)</summary> ### [`v11.17.0`](https://redirect.github.com/zwave-js/zwave-js-ui/blob/HEAD/CHANGELOG.md#11170-2026-05-05) [Compare Source](https://redirect.github.com/zwave-js/zwave-js-ui/compare/v11.16.2...v11.17.0) ##### ✨ Features - **hass:** add suggested\_area from node location ([#​4627](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4627)) ([b9544ec](https://redirect.github.com/zwave-js/zwave-js-ui/commit/b9544ecd21d005d5b35769cc245d17e8a01a2455)) ##### 🐛 Bug Fixes - socket reconnection loop and trust proxy validation error ([#​4604](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4604)) ([aed2082](https://redirect.github.com/zwave-js/zwave-js-ui/commit/aed2082a6576576783d6264e755ce42d6580f218)), closes [#​4564](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4564) [#​4535](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4535) [home-assistant/addons#4597](https://redirect.github.com/home-assistant/addons/issues/4597) [#​4535](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4535) ##### 🔧 Chores - **deps:** move frontend-only deps out of runtime deps ([#​4630](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4630)) ([0ca1850](https://redirect.github.com/zwave-js/zwave-js-ui/commit/0ca1850792345fd88c0e623c8e00940433e2e37a)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://redirect.github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMzAuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEzMC4xIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbImFwcC96d2F2ZWpzMm1xdHQiLCJhdXRvbWVyZ2UiLCJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL21pbm9yIl19-->
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [zwavejs/zwave-js-ui](https://redirect.github.com/zwave-js/zwave-js-ui) | minor | `11.15.1` → `11.18.0` | --- ### Release Notes <details> <summary>zwave-js/zwave-js-ui (zwavejs/zwave-js-ui)</summary> ### [`v11.18.0`](https://redirect.github.com/zwave-js/zwave-js-ui/blob/HEAD/CHANGELOG.md#11180-2026-05-18) [Compare Source](https://redirect.github.com/zwave-js/zwave-js-ui/compare/v11.17.0...v11.18.0) ##### ✨ Features - bump zwave-js\@​15.24.0 ([#​4634](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4634)) ([6daab13](https://redirect.github.com/zwave-js/zwave-js-ui/commit/6daab1340d91636ed2f676c77d7a093c87f30ab3)) - **hass:** add reactive\_power/reactive\_energy, expand HA sensor device classes, and fix unit casing ([#​4629](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4629)) ([7e61d4b](https://redirect.github.com/zwave-js/zwave-js-ui/commit/7e61d4b35435edf3c27e77a56f6bebec62aeccd7)) ##### 🐛 Bug Fixes - **zwave:** restore debug log level on driver restart during capture session ([#​4628](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4628)) ([f6dc9f2](https://redirect.github.com/zwave-js/zwave-js-ui/commit/f6dc9f2488f857ccf204e92f54e4d6d5a42a19a1)) ### [`v11.17.0`](https://redirect.github.com/zwave-js/zwave-js-ui/blob/HEAD/CHANGELOG.md#11170-2026-05-05) [Compare Source](https://redirect.github.com/zwave-js/zwave-js-ui/compare/v11.16.2...v11.17.0) ##### ✨ Features - **hass:** add suggested\_area from node location ([#​4627](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4627)) ([b9544ec](https://redirect.github.com/zwave-js/zwave-js-ui/commit/b9544ecd21d005d5b35769cc245d17e8a01a2455)) ##### 🐛 Bug Fixes - socket reconnection loop and trust proxy validation error ([#​4604](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4604)) ([aed2082](https://redirect.github.com/zwave-js/zwave-js-ui/commit/aed2082a6576576783d6264e755ce42d6580f218)), closes [#​4564](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4564) [#​4535](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4535) [home-assistant/addons#4597](https://redirect.github.com/home-assistant/addons/issues/4597) [#​4535](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4535) ##### 🔧 Chores - **deps:** move frontend-only deps out of runtime deps ([#​4630](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4630)) ([0ca1850](https://redirect.github.com/zwave-js/zwave-js-ui/commit/0ca1850792345fd88c0e623c8e00940433e2e37a)) ### [`v11.16.2`](https://redirect.github.com/zwave-js/zwave-js-ui/blob/HEAD/CHANGELOG.md#11162-2026-04-27) [Compare Source](https://redirect.github.com/zwave-js/zwave-js-ui/compare/v11.16.1...v11.16.2) ##### ✨ Features - bump [@​zwave-js/server](https://redirect.github.com/zwave-js/server)@​3.8.0 ([#​4621](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4621)) ([d6902dc](https://redirect.github.com/zwave-js/zwave-js-ui/commit/d6902dc946373e97f8444aa6bd234f4fa0ccbff1)) - bump zwave-js\@​15.23.5 ([#​4620](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4620)) ([dd4bf1e](https://redirect.github.com/zwave-js/zwave-js-ui/commit/dd4bf1e90dffde0f04a3830e2235c4d22ffba7df)) ### [`v11.16.1`](https://redirect.github.com/zwave-js/zwave-js-ui/blob/HEAD/CHANGELOG.md#11161-2026-04-22) [Compare Source](https://redirect.github.com/zwave-js/zwave-js-ui/compare/v11.16.0...v11.16.1) ##### ✨ Features - bump zwave-js\@​15.23.2 ([#​4615](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4615)) ([a21b2d8](https://redirect.github.com/zwave-js/zwave-js-ui/commit/a21b2d8be31ec701dfcb2fe3d7bdaabac479ed21)) - bump zwave-js\@​15.23.4 ([#​4618](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4618)) ([d496275](https://redirect.github.com/zwave-js/zwave-js-ui/commit/d496275a2993457f772d4f93e3db6f6f7a561d00)) ##### 🔧 Chores - **deps:** pin `zwave-js` dependency ([#​4617](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4617)) ([da840fe](https://redirect.github.com/zwave-js/zwave-js-ui/commit/da840feab7581409275389ec5bdcc579d33de7d1)) ### [`v11.16.0`](https://redirect.github.com/zwave-js/zwave-js-ui/blob/HEAD/CHANGELOG.md#11160-2026-04-13) [Compare Source](https://redirect.github.com/zwave-js/zwave-js-ui/compare/v11.15.1...v11.16.0) ##### ✨ Features - bump zwave-js\@​15.22.2 ([#​4600](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4600)) ([1e66ea6](https://redirect.github.com/zwave-js/zwave-js-ui/commit/1e66ea693809a91090cf54b23b70ab89c94003e3)) - bump zwave-js\@​15.23.0 ([#​4613](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4613)) ([802f564](https://redirect.github.com/zwave-js/zwave-js-ui/commit/802f56424d6b418406ba440fd6d36eb4cc7f2062)) - **ui:** move pagination to top of nodes table ([#​4605](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4605)) ([08b46dc](https://redirect.github.com/zwave-js/zwave-js-ui/commit/08b46dc62780369a21b725f93451c1098cf72008)), closes [#​3603](https://redirect.github.com/zwave-js/zwave-js-ui/issues/3603) [#​4488](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4488) ##### 🐛 Bug Fixes - **docs:** clarify default value of BACKUPS\_DIR ([#​4597](https://redirect.github.com/zwave-js/zwave-js-ui/issues/4597)) ([0224aca](https://redirect.github.com/zwave-js/zwave-js-ui/commit/0224aca52e2f784e2dbc3ce71e3f2adf07d24471)) - specify exact Node.js version in release workflow ([c80566f](https://redirect.github.com/zwave-js/zwave-js-ui/commit/c80566f7d02136dbe65bc39ad57900a023b9e43a)) </details> --- ### Configuration 📅 **Schedule**: (in timezone America/Los_Angeles) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/markis/cluster-config). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xODUuMSIsInVwZGF0ZWRJblZlciI6IjQzLjE4NS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sorry for the late reply. Best practice is to not use the same port to expose the web interface optionally outside ( Instead, set Note that with ESPHome and Music Assistant thins are a bit more complicated since they operate with |
|
Btw, there is also the idea to support ingress via Unix domain socket which is by nature only available local and would secure access quite nicely. |
|
I've started implementing the 2nd server approach in Z-Wave JS UI. I'll go with that. |
Fixes the issues reported in zwave-js/zwave-js-ui#4535
Summary by CodeRabbit