# Putting artifacts on a site [中文](hosting.zh-CN.md) Open Artifact makes artifacts (slides, docs, sheets, dashboards, whiteboards, designs, motion) on your own computer. A **site** is a server that gives those artifacts a **web address** that works when your computer is off. People sign in there, open what is shared with them, edit and comment together. Your agent **publishes** an artifact to the site, and keeps working on it from your computer. This page explains how a site works and helps you pick where to run one. The step-by-step guides are linked at the end. > **If you are an agent doing this for someone** > > - Ask, never guess: the domain names; which cloud account to use; who may sign up; whether artifacts may be made > public; whether a dashboard's data may be published. > - **One domain for both** (`OA_CONTENT_SAME_SITE=true`) is the person's decision, never yours. Offer a second name > first (a second domain, `nip.io` on a LAN, `workers.dev` on Cloudflare). If there is none, show them > [what it weakens](#one-domain-for-both) and turn it on only after they say yes to that. > - Only the person can: add DNS records, sign in with the owner key, approve a computer, pay or accept a plan. > - Never print a secret (signing keys, the owner key, Link tokens, OAuth secrets). Say where it is stored instead. > - Ask before you create or delete a cloud resource, or anything that costs money. > - Check each step with its **Check:** command before the next one. After two failures of the same step, stop and > report what you ran and what you saw. ## The words The product and the code use different words for the same things. The guides use the product's words. | In these guides | In the code and the logs | What it is | | --- | --- | --- | | site | host | The server: Node (`packages/host`) or Cloudflare (`packages/host-cloudflare`). | | web address | view URL, `/a/` | Where an artifact opens on the site. | | connect a site | `remote add` | Link your computer's Open Artifact to a site. | | publish / unpublish | Link `import` / `unpublish` | Put an artifact on the site, or take it off. | | your computer's Open Artifact | the daemon | The local program the agent apps start. It keeps a folder per artifact. | | room | artifact object, room | The live copy of one artifact on the site (on Cloudflare, one Durable Object). | ## How the parts fit ``` agent app (Claude Code, Codex, Cursor, ...) | MCP tools v Open Artifact on your computer ----- publish, then sync both ways -----> site (the daemon, one folder per artifact) <---- comments, requests, edits --- (app origin + content origin) ^ people, in a browser ---+ remote MCP clients -----+ ``` - The agent makes and edits the artifact on your computer, as without a site. - **Publish** copies the artifact to the site. From then on, the folder on your computer is a **working copy**: your changes are pushed to the site, and changes people make on the site come back to the folder. If the two collide, the site's version wins and yours is kept under `_agent/conflicts/` in the folder. - Comments and requests people send to "the agent" on the site reach your computer's Open Artifact, which hands them to your agent. If your computer is off, they wait on the site. - **Unpublish** moves the site's copy to the site's trash. The folder stays on your computer with the latest changes. The trash keeps it for `OA_TRASH_DAYS` days (30 by default; `0` keeps it until its owner deletes it forever), and the home page's trash says how long. The home page's **Upload** takes a `.zip` up to the site's limit (100 MiB on Node, 32 MiB on Cloudflare) and refuses a larger one before sending it. - An agent that cannot run Open Artifact locally can use the site directly over **remote MCP** (`/mcp` on the site). ## Two web origins A site answers on two origins: | | Example | Serves | Cookies | | --- | --- | --- | --- | | **App origin** (`OA_APP_ORIGIN`) | `https://artifacts.example.com` | sign-in, the home page, the Shell (the frame around each artifact), sharing, the APIs, `/mcp` | the session cookie | | **Content origin** (`OA_CONTENT_ORIGIN`) | `https://{id}.oa-content.example.net` | each artifact's own pages, one host name per artifact | none; a short-lived page token is in the address | Why: an artifact's page is HTML that a person or an agent wrote. It must never be able to read the session cookie, or it could act as whoever opens it. So: - The content origin must be a **different registrable domain** from the app (`example.net` against `example.com`, not just another sub-domain). Both hosts refuse to start otherwise. - `{id}` must be the whole first label of the content host. It is the artifact id with `_` turned into `-`, so `art_0mwr…` is served at `art-0mwr….oa-content.example.net`. The content origin therefore needs a **wildcard** DNS name. **Which name answers what.** In every layout (two domains, one domain, a LAN, Node or Cloudflare) the site looks at the name a request was sent to (its `Host`, upper or lower case, with the default port or without) and answers: - the app, with every app route (sign-in, pages, APIs, `/mcp`, `/link/…`, `/plugins/…`), only on the app origin's own host and port, exactly as `OA_APP_ORIGIN` has it; - an artifact's pages only on that artifact's content host; - any other name that reaches it (another name of the domain such as `www.example.com`, the bare content domain, the server's IP address when the app is a name, `localhost` when the app is `127.0.0.1`, a name with a trailing dot) with **421** and one line of text, ` is not this site's app host nor an artifact's: Open Artifact does not answer it.`: no page, no cookie, no redirect, no form, on GET and on writes alike; - a request without a usable `Host` (missing, or not a host name) with **400** `The request has no valid Host header.` The health check (`/__open-artifact/health`) is the one exception: it answers on any name, so a load balancer or a container check can probe the server by address. Behind a proxy, the host the site judges is `X-Forwarded-Host` only with `OA_TRUST_PROXY=1` on Node; otherwise it is the `Host` the proxy sent, so the proxy must pass the original name on. How "registrable domain" is judged: the last two labels of the name (`example.com`), except that `nip.io`, `sslip.io` and `home.arpa` names use three (`192-168-1-20.nip.io`), and an IP address is its own site. So on a LAN, `oa.lan` and `oa-content.lan` are two sites, but `nas.lan` and `{id}.nas.lan` are one, and are refused. A person with one domain should first use a second name that is a different site: a second domain, a `nip.io` name on a LAN, or Cloudflare's `workers.dev` address for the app. When there is truly only one, the site can run with both on it, weaker in the ways the next section lists: [One domain for both](#one-domain-for-both). ## One domain for both `OA_CONTENT_SAME_SITE=true` lets the content origin sit on the app's own registrable domain: | | App origin | Content origin | | --- | --- | --- | | Server | `https://app.example.com` | `https://{id}.example.com` | | LAN | `http://nas.lan:4900` | `http://{id}.nas.lan:4900` | | Cloudflare, one zone | `https://app.example.com` (Custom Domain) | `https://{id}.example.com` (route) | Without the setting such a pair is refused, with a message that names it: ``` open-artifact-host: OA_CONTENT_ORIGIN: must be a different site from OA_APP_ORIGIN (http://nas.lan:4977), so that artifact pages cannot reach the session cookie: use another registrable domain. With only one domain, OA_CONTENT_SAME_SITE=true allows it, at a cost: read "One domain for both" in docs/hosting.md first. ``` Even with it, the hosts stay apart. The app's host is never a content host nor a name under one: an app at `art-app.nas.lan` is refused, because every `art-…` label is an artifact's. (A content host under the app's host, as `art-….nas.lan` beside `nas.lan`, is allowed.) Every other name of the domain, such as `www.example.com`, gets the 421 described in [Two web origins](#two-web-origins), as in every layout. The guides show how to set it up: [LAN](hosting-lan.md#one-domain-for-both), [server](hosting-server.md#one-domain-for-both), [Cloudflare](hosting-cloudflare.md#one-domain-for-both). ### What it weakens, and what the site does about it Two origins on two sites keep an artifact's page (HTML a person or an agent wrote) away from the app in every way a browser knows. On one site, the browser treats the two as neighbours. Each way that matters: - **The app's cookies go along with an artifact page's requests.** The session cookie is `SameSite=Lax`, and "same site" is exactly this case, so a page on `art-….example.com` that sends a request to `app.example.com` sends the person's session with it. What the site does: every write on the app origin (each route that is not GET, HEAD or OPTIONS, and the MCP sign-in approval) from a browser is refused unless it comes from the app's own pages: `Sec-Fetch-Site` must be `same-origin`, and a `same-site` request is refused like a `cross-site` one (403 `not_granted`); `none` (typed in the address bar) passes only without cookies, so it cannot use a session. A client that sends no `Sec-Fetch-Site` (the Link daemon, curl, an old browser) is judged by `Origin`: absent or the app origin passes, any other value (`null` included) is refused; such a client acts through its own credential (a Bearer token, or a session cookie it holds), never through a browser's. The GETs that used to change something now do so only on a visit to the page: opening a share link joins only on a top-level visit that did not come from a neighbour host, otherwise it shows a page with an **Open it** button; sign-in's start and callback refuse an image, a fetch or a frame. Other GETs change nothing a person would notice (opening an artifact starts its room; it does not grant anything). The site's tests walk every write route of the router to check this. A site plugin's own GET routes are the plugin's responsibility. - **An artifact page tries to read the app's answers.** Same-site does not mean same-origin, so the browser still withholds them unless the app allows it, and it does not: no CORS for content hosts, and every app answer carries `Cross-Origin-Resource-Policy: same-origin`, so an ``, `