Repository navigation
Preview host: frames open on preview.openrepl.com/<token>/..., without /preview - #176
Merged
Merged
Conversation
…hout /preview SiteSettings.PreviewBaseURL (Site settings > Workspaces > Preview; a host name such as preview.openrepl.com, https assumed, no path; empty by default) moves the frames of the Preview to https://preview.openrepl.com/<token>/f/index.html and /<token>/p/<port>/... Empty keeps every address as it was. A thin layer over the routes that exist (server/previewhost.go, the outermost handler of the site, the gateway and a worker): on the host every path is turned into the site's own form (/preview/<token>/...) and marked, then served by the same handlers, so the token, storage, libraries, programs and the routing to workers are unchanged. Nothing of the site is reachable there: every path ends below /preview/ (a non-token is 410), the root is 404. /preview/<token>/... stays valid on the site and on the host. The form follows the request: the prefix a program's links are rewritten to, the storage URL and the trailing-slash redirect use /<token>/... on the host. The gateway forwards the mark to a worker in a trusted header (stripped from clients, believed only over the tunnel); the setting reaches workers in WorkerConfig. Page (27-preview.js): the history keeps the site's form; pub(), popUrl() and pathOf() make and read the addresses of frames, tabs and copy. LLD 17 'The preview host'. Tests: the layer, both forms, the file route on both hosts, the setting, worker config, the mark to a worker, the page functions. Not run: browser specs, a real second host. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The Preview base URL is kept as the admin typed it (no https:// added); the scheme is derived where a full address is needed (http for a local host, https otherwise). The host match and the check against OPENREPL_PUBLIC_URL compare host names only, not scheme or port. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…; new tab uses the preview host The setting is sent to the page and the workers as typed. The page adds the scheme and port of the site it was opened from when none was typed. The "Open in new tab" button now goes through popUrl like the pop-out window. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
Optional Preview base URL (Site settings > Workspaces > Preview; a host name such as
preview.openrepl.com, https assumed, no path). When set, the Preview frames, "open in a tab" and "copy address" usehttps://preview.openrepl.com/<token>/f/index.htmland/<token>/p/<port>/...instead ofhttps://openrepl.com/preview/<token>/.... Empty (default) keeps every address as it was. Built on the partial diff inpreview_url_partail.diff(setting, validation, admin field, worker config).How (minimal)
server/previewhost.gowrapPreviewHost, the outermost handler of the site, the gateway and a worker: on the preview host every path is turned into the site's own form (/preview/<token>/...) and marked; the same handlers serve it, so token validation, storage, libraries, programs and routing to workers are unchanged./preview/(a non-token gives the "preview ended" 410), the root is 404./preview/<token>/...is accepted on the host; the site's own/preview/...is unchanged./<token>/...on the host (previewPath,publicPath).X-Openrepl-Preview-Host), stripped from clients, believed only over the tunnel; the setting reaches workers inWorkerConfig.27-preview.js): the tab history keeps the site's form;pub(),popUrl(),pathOf()make and read frame/tab addresses.settings.jscarries the setting.To use
Point the host's DNS at the OpenREPL server, give it a certificate, and keep the Host header on the way (e.g. Cloudflare). If a CSP is set in front, it must allow the preview origin in a frame. Then enter
preview.openrepl.comin the admin field and reload.Tests
Go: the layer (both forms, the site untouched,
/adminand root on the host), the file route on both hosts, the setting (bare host accepted, path/query/credentials refused), the mark to a worker (and a client's copy dropped), worker config. JS:preview-host.test.mjs.server,gateway,tunnel,trusted,livepreviewGo tests and the page script tests pass. Not run: browser (e2e) specs and a real second hostname.🤖 Generated with Claude Code