Skip to content

Local item URL fallbacks#2207

Merged
lissy93 merged 2 commits into
masterfrom
feat/local-url-remote-access
Jun 14, 2026
Merged

Local item URL fallbacks#2207
lissy93 merged 2 commits into
masterfrom
feat/local-url-remote-access

Conversation

@lissy93

@lissy93 lissy93 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Category

Feature

Overview

Adds localUrl option for items. Which, if specified will check if reachable (e.g. on LAN) and use that as the link, otherwise falling back to the normal url attribute.

This is a re-open fixes #2205 submitted by @Troublesis
But was missing the PR edit permissions, so I need to re-submit it to get changes in. (don't worry Troublesis, you'll still show as contributor of your work 😉).

The only changes I have made since the original PR was:

  • Lifecycle moved into the mixin - mounted/beforeUnmount now live in ItemMixin, so both Item.vue and SubItem.vue inherit instead of duplicating logic
  • In-flight probe now aborted during teardown, so no pending fetch left dangling
  • Trimmed verbosity, some of the docs and comments were overly long and unnecisary

Issue Number

#1313


Original PR body from

What this does

Adds an optional localUrl to dashboard items: an alternative URL (typically a LAN address) that is used only when it is reachable from the visitor's browser, otherwise the item falls back to the regular url.

This solves the long-standing local-vs-remote access problem described in #1313: when you reach Dashy over a VPN/Tailscale/remote tunnel, LAN addresses and local DNS don't resolve, so a single hard-coded URL can't serve both contexts. With localUrl, the same item "just works" on LAN (direct, fast) and remotely (falls back to the public/proxied URL) — no manual switching.

How it works

  • On mount, if an item has a localUrl, Dashy probes it in the background with a no-cors fetch (we only care whether the request settles vs. aborts/errors — not its contents, so cross-origin LAN services don't trip CORS).
  • The result drives a new effectiveUrl computed, which is already bound to the anchor href before the user clicks — so the probe never delays a click. Until the probe confirms reachability, the regular url is used.
  • Re-probes when the tab regains visibility (e.g. the user changed networks), and optionally on a configurable interval.

New item options

Key Type Default Description
localUrl string Alternative URL preferred when reachable from the browser
localUrlTimeout number 1500 Probe timeout in ms, clamped 3005000
localUrlCheckInterval number 0 Seconds between background re-checks; 0 = only on load + tab focus, clamped to 300 max

All three are optional and fully backwards-compatible — items without localUrl behave exactly as before.

Changes

  • src/mixins/ItemMixin.js — probe logic, effectiveUrl computed, timers/listener lifecycle
  • src/components/LinkItems/Item.vue — bind effectiveUrl, start/stop probing on mount/unmount
  • src/components/LinkItems/SubItem.vue — same lifecycle hooks for sub-items
  • src/utils/config/ConfigSchema.json — schema for the three new properties
  • docs/configuring.md — documents the new options

Example

- title: Home Assistant
  url: https://ha.example.com        # used when remote
  localUrl: http://192.168.0.10:8123 # preferred when on the LAN
  localUrlTimeout: 1500
  localUrlCheckInterval: 0

Notes

Closes the use case in #1313 (the issue was closed as not planned; opening this in case the maintainers reconsider, since the implementation is self-contained and opt-in). Timers and the visibilitychange listener are cleaned up in beforeUnmount to avoid leaks in multi-page navigation.

Troublesis and others added 2 commits June 14, 2026 11:13
Introduce an optional per-item localUrl (e.g. a LAN address) that is
preferred over the regular url when reachable from the browser. A
background probe (default 10s interval, 5s timeout) checks
reachability of localUrl and falls back to url when unreachable,
enabling seamless remote/LAN switching without manual config changes.

- ItemMixin: add effectiveUrl computed + probe lifecycle (mount/destroy)
- Item/SubItem: expose localUrl-driven effective url to templates
- ConfigSchema: add localUrl, localUrlTimeout, localUrlCheckInterval
- docs/configuring.md: document the new properties

Closes #1313
@lissy93 lissy93 merged commit 4dabcf1 into master Jun 14, 2026
12 checks passed
@lissy93 lissy93 deleted the feat/local-url-remote-access branch June 14, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants