Skip to Content

Open an app on a machine as a preview

A preview gives an app that listens on a machine’s own port an address on the web: https://<name>-<address>.cmdop.page. The app keeps running where it is; nothing is deployed and no port is opened on the machine.

Who can open a preview

KindWho gets in
Private (the default)the owner, signed in to their page; an agent granted http; a person with a share link
Public (--public)anyone with the address, as for a demo

The app sees itself at http://localhost:<port>, so host and origin checks of common dev servers pass with no setting. The app never sees a CMDOP token or sign-in.

Open one (person at the machine)

Run on the machine where the app runs:

cmdop expose 3000 --name shop
  • --name is the first part of the address: 1 to 20 of a-z and 0-9, no dashes (webstorybook, not storybook-web). Without it the name is the port.
  • The machine asks before opening, and opens the address in the browser when you sit at its screen. --no-open only prints it.
  • --public lets anyone in without signing in.
  • cmdop expose --list shows what is open; cmdop expose --stop shop closes it.

A container opens itself. Give the container that runs the app the label cmdop.preview.name=<name> (Docker Compose: labels: ["cmdop.preview.name=shop"]). While it runs it is a private preview with no command; when it stops, the preview leaves the list a minute later and comes back under the same address. "http": { "ignore_declared": true } in the machine’s ceiling.json turns this off.

From the page. The Previews page lists the ports a machine listens on that answer HTTP. A switch opens one as a private preview, also from a phone.

Look at it (owner)

Open the address. A browser that is not signed in shows “Sign in with CMDOP”; one click through your page signs that browser in to this preview only. The Previews page shows every open preview with its machine, the browsers signed in (and how many are agents), Copy, Share and Close.

Share it with someone

On the preview, Share makes a short link (https://s.cmdop.page/...) for 1 hour, 1 day or 7 days, with an optional note (“for Acme”). Whoever opens it gets this preview only, nothing else of your account. The link is shown once; revoke it on the page and its browsers are signed out at their next request.

Let an agent see it (agent)

  1. Your grant needs http: the owner turns on Open your previews for you on All machines → Agents, or when approving your connection (grant risk classes). The owner must also give you the machine the preview runs on.
  2. previews_list lists the previews you may open: name, address, port, private or public.
  3. preview_open with the name returns a link for your own browser: it opens within 10 minutes, at most three times, and signs that browser in to this preview as you. Keep it secret. A public preview returns its address.
  4. Look and act in your browser: real fonts, hover, clicks. Your sign-in ends when your token is revoked or loses http or the machine, and when the preview closes.

An agent cannot open, share or close a preview; that stays with the person at the machine and the owner.

What does not work yet

  • Absolute http://localhost links written into a page’s content.
  • A sign-in with another service that sends you back to a redirect_uri the app built as localhost.
  • An app that forces HTTPS on itself.
  • A Content Security Policy that names localhost.

If it fails

What you seeWhat to do
The name is refusedUse 1 to 20 of a-z and 0-9, no dashes
“offline”The machine is not connected, or the app stopped; start it and reload
403 “not granted http”The owner turns on Open your previews for the agent on All machines → Agents
403 “not given the computer of this preview”The owner adds the machine to your token
“This link has expired or was turned off”Ask for a new link, or call preview_open again

Grant risk classes · Risk classes · Set the ceiling