Skip to content

feat: support reverse-proxy public URLs - #1266

Merged
backnotprop merged 8 commits into
backnotprop:mainfrom
Whamp:feat/plannotator-public-url
Oct 28, 2026
Merged

backnotprop merged 8 commits into
backnotprop:mainfrom
Whamp:feat/plannotator-public-url

Conversation

@Whamp

@Whamp Whamp commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Why this exists

I typically use Plannotator from Pi inside Herdr, with Herdr exposed through a Cloudflare Tunnel and Access. Some machines I work from cannot join my tailnet, so the browser-facing and local addresses differ:

Browser:  https://plannotator.example.com
Origin:   http://127.0.0.1:19432

PLANNOTATOR_URL_HOST cannot represent this setup. It accepts only a hostname and appends Plannotator's runtime port, producing http://plannotator.example.com:19432. Cloudflare instead terminates HTTPS on port 443 and forwards requests internally to port 19432.

This PR adds a separate public URL setting:

PLANNOTATOR_REMOTE=1
PLANNOTATOR_PORT=19432
PLANNOTATOR_PUBLIC_URL=https://plannotator.example.com

Plannotator still listens on the local runtime address and uses loopback URLs for same-machine agent communication. It uses the public URL only when advertising or opening the review session.

A port range also supports concurrent directly reachable sessions while one reverse-proxy origin remains mapped to the first port:

PLANNOTATOR_REMOTE=1
PLANNOTATOR_PORT=19432-19463
PLANNOTATOR_PUBLIC_URL=https://plannotator.example.com
PLANNOTATOR_URL_HOST=my-machine.tailnet.ts.net

The session on 19432 advertises the public origin. Sessions on later ports advertise http://my-machine.tailnet.ts.net:<port>. Concurrent public sessions still require a session-aware proxy.

The same public/local distinction applies to nginx, Caddy, Kubernetes ingress, SSH gateways, and other reverse proxies.

Summary

  • add PLANNOTATOR_PUBLIC_URL and publicUrl for remote sessions behind a reverse proxy
  • advertise the full HTTP(S) origin without appending the local runtime port
  • use the public origin only for the first port in a configured range, then fall back to PLANNOTATOR_URL_HOST:<port>
  • preserve local binding and loopback agent APIs
  • centralize advertised-URL selection and local-only URL classification in one shared module used by both server runtimes
  • document authenticated HTTPS reverse-proxy deployment and range behavior

Validation

  • focused shared-policy, public-URL, range, adapter, and terminal-guidance tests: 132 passed
  • full suite: 3,461 passed, 545 skipped; one pre-existing Pi call-flow concurrency test failed identically at the pre-cleanup PR head and is outside this diff
  • TypeScript checks passed for core, shared, AI, server, UI, strict UI consumer, and Pi extension configs
  • oxlint and oxfmt: clean for the new shared module
  • aislop: 0 errors
  • maintained-source slop-scan delta: 234 → 234 findings, 0 added or worsened occurrences

@Whamp
Whamp force-pushed the feat/plannotator-public-url branch from 702a2bc to c79ac55 Compare August 13, 2026 20:43
@Whamp
Whamp force-pushed the feat/plannotator-public-url branch from 99ee32a to c987b56 Compare September 17, 2026 20:42
backnotprop and others added 5 commits October 28, 2026 12:31
A reverse proxy that forwards the browser's Host (Cloudflare Tunnel,
Caddy) got 403 unless the user also listed the hostname in
PLANNOTATOR_ALLOWED_HOSTS. Both Host guards now add the hostname of
PLANNOTATOR_PUBLIC_URL to the remote-mode names, with Bun and Pi
scenarios, and the docs say so.
--tailscale binds loopback, so a configured publicUrl brought back the
"set PLANNOTATOR_REMOTE=1" warning mid-run. Clear it there like urlHost.
The remote guide now says a plain-http public URL behind a Host-rewriting
proxy also needs PLANNOTATOR_ALLOWED_HOSTS.
…ode effects

PLANNOTATOR_PORT=0 binds a port no proxy can target, so the port-less
public origin pointed nowhere; it now falls back to the normal address
with the real port. Docs say a same-machine tunnel needs
PLANNOTATOR_REMOTE=1 (all interfaces, Ask this session off) and that
live app annotation stays on localhost.
@backnotprop
backnotprop merged commit 5cd90cc into backnotprop:main Oct 28, 2026
29 checks passed
backnotprop added a commit to utpalsinghdev/plannotator that referenced this pull request Oct 28, 2026
Resolve conflicts with backnotprop#1266 (reverse-proxy public URLs). The localhost
rule moves into the shared resolveAdvertisedSessionUrl so both runtimes
keep parity: a remote session advertises the public URL on the port it
fronts and ignores a *.localhost urlHost; a local session ignores the
public URL and honors plannotator.localhost.

Co-Authored-By: Claude <[email protected]>
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.

3 participants