Support single-host path/port routing, and modernize the example stack#332
Merged
Conversation
Let self-hosters run the whole stack on one host under path prefixes
(example.org/api, example.org/gateway) instead of a subdomain per service.
- api/lcg: mount under an optional path prefix via UsePathBase
(OpenShock:Api:PathBase, OPENSHOCK__LCG__PUBLICPATH). Traefik routes by
PathPrefix without stripping, so generated URLs (OAuth redirect_uri, Scalar)
keep the prefix.
- lcg: advertise a configurable public port/path (LcgOptions.PublicPort/
PublicPath); self-register under a composite node id host[:port][/path] that
stays byte-identical to the old bare-host key on the default port/root path.
- redis: re-key LcgNode on that composite id; rename Fqdn -> Host, add Port and
PathPrefix (index lcg-online-v4 -> v5).
- assignLCG v2 now returns the real Host/Port/Path; add a v2 {deviceId}/lcg that
returns the gateway host/port/base-path so the browser builds the live-control
URL itself. v1 endpoints stay bare-host:443 legacy.
- refactor the shared gateway lookup to OneOf<LcgNode, OpenShockProblem>.
- tests: cover path/port propagation and default backward-compatibility.
|
Ready to review this PR? Stage has broken it down into 8 individual chapters for you: Chapters generated by Stage for commit 0237125 on Jul 4, 2026 4:37pm UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1aaed76661
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Self-hosting currently assumes a subdomain per service (
api.,gateway.,frontend on the apex), which needs wildcard-capable DNS and creates a
cross-subdomain login-cookie trap. This PR lets a self-hoster run the whole stack
on one host + one port, telling services apart by path:
https://host/ -> frontend
https://host/api/... -> api (OPENSHOCK_API_PATH)
https://host/gateway/… -> gateway (OPENSHOCK_GATEWAY_PATH)
Everything is one origin, so the cookie "just works" with no apex juggling.
Backend routing (
feat(routing))UsePathBaseon the API and gateway via config (OpenShock:Api:PathBase,OPENSHOCK__LCG__PUBLICPATH). Traefik routes byPathPrefixwithoutstripping, so each app owns its prefix and generated URLs (OAuth
redirect_uri,Scalar) stay correct. API host/port stay implicit (forwarded headers); only the
gateway needs an explicit
PublicPort/PublicPathsince it advertises itselfout-of-band.
LcgNodere-keyed on a composite public idhost[:port][/path](
Fqdn→Host, addedPort/PathPrefix, indexlcg-online-v4→v5). The id isbackward-compatible: a default port/root gateway keeps the exact bare-host key
it has today, so existing
DeviceOnline.Gatewaypointers keep resolving.assignLCGv2 now returns the realHost/Port/Path; new v2{deviceId}/lcgreturns the gateway's host/port/base-path so the browser buildsthe live-control URL itself. v1 endpoints stay bare-host:443 legacy.
OneOf<LcgNode, OpenShockProblem>.Example stack rework (
feat(docker-compose)).env(OPENSHOCK_HOST,OPENSHOCK_PORT,*_PATH);${PORT:+…}keeps cleanhttps://hostURLs at 443.--notify_keyspace_events=Ex)./var/lib/postgresql).webui→frontend(PUBLIC_*env), short-link middlewares dropped.Backward compatibility
Defaults (
OPENSHOCK_PORTunset, gateway path empty) reproduce today's exact wirebehavior. Path/port gateways only work with v2-capable firmware that honors the
v2 assign
Host/Port/Path; hubs on v1 firmware must stay on the defaultport/root path.
Testing
svelte-checkclean.docker compose configvalidated for both default and custom-port (8080).LcgAssignmentTestsextended with path/port propagation + default back-compatcases (run these in CI — Testcontainers needs a Docker daemon).
Follow-ups (not in this PR)
getGatewayWsURL,live-control v2 discovery); the API SDK must be regenerated against the
deployed API to replace the temporary shim.
This desc was generated with an LLM.