@conloca/cloud-astro 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/README.md +261 -208
  2. package/dist/.build-inputs.json +60 -0
  3. package/dist/src/component-manifest.d.ts +5 -3
  4. package/dist/src/component-manifest.d.ts.map +1 -1
  5. package/dist/src/component-manifest.js +7 -7
  6. package/dist/src/component-manifest.js.map +1 -1
  7. package/dist/src/constants.d.ts +5 -13
  8. package/dist/src/constants.d.ts.map +1 -1
  9. package/dist/src/constants.js +5 -13
  10. package/dist/src/constants.js.map +1 -1
  11. package/dist/src/descriptors.d.ts +2 -2
  12. package/dist/src/descriptors.d.ts.map +1 -1
  13. package/dist/src/doctor/checks-address.d.ts +18 -0
  14. package/dist/src/doctor/checks-address.d.ts.map +1 -0
  15. package/dist/src/doctor/checks-address.js +163 -0
  16. package/dist/src/doctor/checks-address.js.map +1 -0
  17. package/dist/src/doctor/checks-live.d.ts +8 -5
  18. package/dist/src/doctor/checks-live.d.ts.map +1 -1
  19. package/dist/src/doctor/checks-live.js +220 -188
  20. package/dist/src/doctor/checks-live.js.map +1 -1
  21. package/dist/src/doctor/checks-offline.d.ts +8 -23
  22. package/dist/src/doctor/checks-offline.d.ts.map +1 -1
  23. package/dist/src/doctor/checks-offline.js +22 -239
  24. package/dist/src/doctor/checks-offline.js.map +1 -1
  25. package/dist/src/doctor/config-scan.d.ts +6 -3
  26. package/dist/src/doctor/config-scan.d.ts.map +1 -1
  27. package/dist/src/doctor/config-scan.js +21 -11
  28. package/dist/src/doctor/config-scan.js.map +1 -1
  29. package/dist/src/doctor/run.d.ts.map +1 -1
  30. package/dist/src/doctor/run.js +12 -10
  31. package/dist/src/doctor/run.js.map +1 -1
  32. package/dist/src/doctor/types.d.ts +7 -7
  33. package/dist/src/doctor/types.d.ts.map +1 -1
  34. package/dist/src/doctor/types.js +7 -7
  35. package/dist/src/doctor/types.js.map +1 -1
  36. package/dist/src/editor-page/bundle.d.ts +88 -0
  37. package/dist/src/editor-page/bundle.d.ts.map +1 -0
  38. package/dist/src/editor-page/bundle.js +370 -0
  39. package/dist/src/editor-page/bundle.js.map +1 -0
  40. package/dist/src/editor-page/emit.d.ts +33 -0
  41. package/dist/src/editor-page/emit.d.ts.map +1 -0
  42. package/dist/src/editor-page/emit.js +183 -0
  43. package/dist/src/editor-page/emit.js.map +1 -0
  44. package/dist/src/editor-page/framing.d.ts +23 -0
  45. package/dist/src/editor-page/framing.d.ts.map +1 -0
  46. package/dist/src/editor-page/framing.js +39 -0
  47. package/dist/src/editor-page/framing.js.map +1 -0
  48. package/dist/src/editor-page/page.d.ts +9 -0
  49. package/dist/src/editor-page/page.d.ts.map +1 -0
  50. package/dist/src/editor-page/page.js +31 -0
  51. package/dist/src/editor-page/page.js.map +1 -0
  52. package/dist/src/editor-page/site-base.d.ts +4 -0
  53. package/dist/src/editor-page/site-base.d.ts.map +1 -0
  54. package/dist/src/editor-page/site-base.js +13 -0
  55. package/dist/src/editor-page/site-base.js.map +1 -0
  56. package/dist/src/git.d.ts +11 -8
  57. package/dist/src/git.d.ts.map +1 -1
  58. package/dist/src/git.js +25 -8
  59. package/dist/src/git.js.map +1 -1
  60. package/dist/src/index.d.ts +3 -1
  61. package/dist/src/index.d.ts.map +1 -1
  62. package/dist/src/index.js +9 -6
  63. package/dist/src/index.js.map +1 -1
  64. package/dist/src/integration.d.ts +1 -1
  65. package/dist/src/integration.d.ts.map +1 -1
  66. package/dist/src/integration.js +245 -408
  67. package/dist/src/integration.js.map +1 -1
  68. package/dist/src/node.d.ts +3 -1
  69. package/dist/src/node.d.ts.map +1 -1
  70. package/dist/src/node.js +7 -2
  71. package/dist/src/node.js.map +1 -1
  72. package/dist/src/preview/_resolve-opts.d.ts +16 -10
  73. package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
  74. package/dist/src/preview/_resolve-opts.js +21 -10
  75. package/dist/src/preview/_resolve-opts.js.map +1 -1
  76. package/dist/src/preview/banner.d.ts.map +1 -1
  77. package/dist/src/preview/banner.js +2 -4
  78. package/dist/src/preview/banner.js.map +1 -1
  79. package/dist/src/preview/cookie.d.ts +5 -2
  80. package/dist/src/preview/cookie.d.ts.map +1 -1
  81. package/dist/src/preview/cookie.js +5 -2
  82. package/dist/src/preview/cookie.js.map +1 -1
  83. package/dist/src/preview/label.d.ts +8 -0
  84. package/dist/src/preview/label.d.ts.map +1 -0
  85. package/dist/src/preview/label.js +14 -0
  86. package/dist/src/preview/label.js.map +1 -0
  87. package/dist/src/preview/landing.d.ts +2 -2
  88. package/dist/src/preview/landing.js +2 -2
  89. package/dist/src/preview/middleware.d.ts +25 -20
  90. package/dist/src/preview/middleware.d.ts.map +1 -1
  91. package/dist/src/preview/middleware.js +56 -51
  92. package/dist/src/preview/middleware.js.map +1 -1
  93. package/dist/src/preview/preview-path.d.ts +18 -5
  94. package/dist/src/preview/preview-path.d.ts.map +1 -1
  95. package/dist/src/preview/preview-path.js +24 -8
  96. package/dist/src/preview/preview-path.js.map +1 -1
  97. package/dist/src/preview/site-middleware.d.ts +5 -5
  98. package/dist/src/preview/site-middleware.d.ts.map +1 -1
  99. package/dist/src/preview/site-middleware.js +16 -16
  100. package/dist/src/preview/site-middleware.js.map +1 -1
  101. package/dist/src/preview-build.d.ts +18 -15
  102. package/dist/src/preview-build.d.ts.map +1 -1
  103. package/dist/src/preview-build.js +36 -21
  104. package/dist/src/preview-build.js.map +1 -1
  105. package/dist/src/preview.d.ts +1 -1
  106. package/dist/src/preview.d.ts.map +1 -1
  107. package/dist/src/preview.js +1 -1
  108. package/dist/src/preview.js.map +1 -1
  109. package/dist/src/repository.d.ts +1 -1
  110. package/dist/src/repository.js +1 -1
  111. package/dist/src/resolve-options.d.ts +17 -0
  112. package/dist/src/resolve-options.d.ts.map +1 -0
  113. package/dist/src/resolve-options.js +21 -0
  114. package/dist/src/resolve-options.js.map +1 -0
  115. package/dist/src/site-id.d.ts +0 -2
  116. package/dist/src/site-id.d.ts.map +1 -1
  117. package/dist/src/site-id.js +2 -3
  118. package/dist/src/site-id.js.map +1 -1
  119. package/dist/src/types.d.ts +21 -69
  120. package/dist/src/types.d.ts.map +1 -1
  121. package/package.json +37 -13
  122. package/src/component-manifest.ts +11 -8
  123. package/src/constants.ts +5 -14
  124. package/src/descriptors.ts +2 -2
  125. package/src/doctor/checks-address.ts +190 -0
  126. package/src/doctor/checks-live.ts +256 -268
  127. package/src/doctor/checks-offline.ts +24 -262
  128. package/src/doctor/config-scan.ts +21 -9
  129. package/src/doctor/run.ts +14 -16
  130. package/src/doctor/types.ts +7 -7
  131. package/src/editor-page/bundle.ts +482 -0
  132. package/src/editor-page/emit.ts +246 -0
  133. package/src/editor-page/framing.ts +62 -0
  134. package/src/editor-page/page.ts +37 -0
  135. package/src/editor-page/site-base.ts +11 -0
  136. package/src/git.ts +29 -10
  137. package/src/index.ts +20 -6
  138. package/src/integration.ts +255 -461
  139. package/src/node.ts +18 -2
  140. package/src/preview/_resolve-opts.ts +29 -11
  141. package/src/preview/banner.ts +2 -4
  142. package/src/preview/cookie.ts +5 -2
  143. package/src/preview/label.ts +12 -0
  144. package/src/preview/landing.ts +2 -2
  145. package/src/preview/middleware.ts +77 -66
  146. package/src/preview/preview-path.ts +26 -8
  147. package/src/preview/site-middleware.ts +16 -21
  148. package/src/preview-build.ts +42 -26
  149. package/src/preview-handler.astro +10 -8
  150. package/src/preview.ts +0 -1
  151. package/src/repository.ts +1 -1
  152. package/src/resolve-options.ts +37 -0
  153. package/src/site-id.ts +2 -4
  154. package/src/skill/SKILL.md +51 -55
  155. package/src/types.ts +21 -70
  156. package/src/virtual-modules.d.ts +4 -1
  157. package/dist/src/build-commit.d.ts +0 -19
  158. package/dist/src/build-commit.d.ts.map +0 -1
  159. package/dist/src/build-commit.js +0 -6
  160. package/dist/src/build-commit.js.map +0 -1
  161. package/dist/src/bundle.d.ts +0 -181
  162. package/dist/src/bundle.d.ts.map +0 -1
  163. package/dist/src/bundle.js +0 -413
  164. package/dist/src/bundle.js.map +0 -1
  165. package/dist/src/discovery.d.ts +0 -58
  166. package/dist/src/discovery.d.ts.map +0 -1
  167. package/dist/src/discovery.js +0 -133
  168. package/dist/src/discovery.js.map +0 -1
  169. package/dist/src/register.d.ts +0 -98
  170. package/dist/src/register.d.ts.map +0 -1
  171. package/dist/src/register.js +0 -103
  172. package/dist/src/register.js.map +0 -1
  173. package/src/build-commit.ts +0 -22
  174. package/src/bundle.ts +0 -570
  175. package/src/discovery.ts +0 -183
  176. package/src/register.ts +0 -180
package/README.md CHANGED
@@ -1,42 +1,52 @@
1
1
  # `@conloca/cloud-astro`
2
2
 
3
- Astro integration that connects a Conloca CMS site to an editor endpoint. Add it to the site's `astro.config.mjs` next
4
- to `conlocaCMS` to:
5
-
6
- 1. Compile the site's Puck config into a single editor bundle under `_conloca/` in the build output
7
- (react/react-dom/jsx-runtime/`@puckeditor/core` stay external — the editor supplies them at runtime) and register the
8
- build at `endpoint`, so the editor there loads this build's bundle for the branch it was built from.
9
- 2. Run a recursive preview build that emits SSR routes for draft content.
10
- 3. Wire preview SSR middleware that checks `/conloca_preview_<secret>/*` requests against the endpoint's token issuer
11
- and serves draft pages.
3
+ Astro integration that adds the editor page for Conloca's workspace editor to a site's build. Add it to the site's
4
+ `astro.config.mjs` next to `conlocaCMS` to:
5
+
6
+ 1. Write the editor page to `/_conloca/editor/` in every build: the site's Puck config compiled into one bundle
7
+ (react/react-dom/jsx-runtime/`@puckeditor/core` stay external — the workspace editor supplies them at runtime), its
8
+ styles, the MDX sandbox frame and `conloca.json`. The page carries no credential.
9
+ 2. When `previewBuild` is given as an object, run a recursive preview build that emits SSR routes for draft content.
10
+ 3. Wire preview SSR middleware that serves `/_conloca/preview/*` under the site's `base` and admits only passes, signed
11
+ by the endpoint's token issuer, for the repository, site and branch the preview build was made from.
12
12
  4. Expose `PreviewContentAPI` for `.astro` pages to fetch draft content.
13
13
 
14
- Items 2 to 4 serve draft previews, which are not available on your own deployment yet. The setup below keeps them off
15
- with `previewBuild: false` (see [Draft previews](#draft-previews)).
14
+ Items 2 to 4 serve draft previews, which are not available on your own deployment yet. They stay off unless
15
+ `previewBuild` is given as an object (see [Draft previews](#draft-previews)).
16
16
 
17
17
  ## Setup
18
18
 
19
19
  Before you start you need:
20
20
 
21
- - An Astro site that already runs `@conloca/astro-cms` (its README covers that), in a GitHub repository.
22
- - The repository connected to the editor at `endpoint`: sign in there with **Continue with GitHub**, choose **Connect
23
- GitHub**, and pick the repository on GitHub's installation screen. If a GitHub organization owns the repository and
24
- you are not one of its owners, an owner has to approve the installation; until then the editor shows **Waiting for
25
- approval**.
26
- - An owner or admin role in the editor's workspace: only they can create the build token in step 3. Whoever sets the
27
- workspace up becomes its first owner.
21
+ - An Astro site in a GitHub repository.
22
+ - The repository connected to your workspace editor at `<slug>.conloca.com`: sign in there with **Continue with
23
+ GitHub**, choose **Connect GitHub**, and pick the repository on GitHub's installation screen. If a GitHub organization
24
+ owns the repository and you are not one of its owners, an owner has to approve the installation; until then the editor
25
+ shows **Waiting for approval**.
26
+ - A place the site is deployed to, at an address visitors reach without signing in. The workspace editor edits the
27
+ deployed site: it opens the editor page your build adds under `/_conloca/editor/`, so editing starts after the first
28
+ deploy. For editing before that, `astro dev` keeps the local editor at `/__cms`.
28
29
 
29
- ### 1. Install
30
+ ### 1. Run `conloca connect`
31
+
32
+ In the site's folder, or the repository holding it:
30
33
 
31
34
  ```sh
32
- bun add @conloca/cloud-astro
35
+ npx @conloca/cli connect
33
36
  ```
34
37
 
35
- It needs Astro 7.3.1 or a later 7.x release, and `@conloca/astro-cms` at its own version: the `@conloca/*` packages are
36
- released together, so keep them on one version and update them together. Its other peers (`@astrojs/react`, `vite`) are
37
- already in a site that runs `@conloca/astro-cms`.
38
+ A coding agent can do the whole setup from one line:
39
+ `In my Astro site's folder, run npx @conloca/cli@<version> connect, then commit, push and deploy.`
40
+
41
+ `connect` adds `@conloca/astro-cms`, `@conloca/cloud-astro`, `@astrojs/react` and `@vitejs/plugin-react` with the
42
+ package manager of the nearest lockfile, wires `astro.config`, writes the site's host into `sites.json` (step 2), adds a
43
+ framing rule only where a committed header file forbids framing (step 3), builds the site once to check that the editor
44
+ page is there, and removes old build key lines from workflows. Every change is shown as a diff first: in a terminal it
45
+ asks once, `--yes` accepts without asking, and `--dry-run` writes nothing. A value you set yourself is kept and reported
46
+ as `differs`. It exits `2` with the lines to add when a step needs you, such as a config that is not a plain
47
+ `defineConfig({ integrations: [...] })`. `npx @conloca/cli connect --help` lists every option.
38
48
 
39
- ### 2. Add it next to `conlocaCMS`
49
+ The config it wires:
40
50
 
41
51
  ```js
42
52
  // astro.config.mjs
@@ -46,6 +56,7 @@ import { conlocaCloud } from '@conloca/cloud-astro';
46
56
  import { defineConfig } from 'astro/config';
47
57
 
48
58
  export default defineConfig({
59
+ site: 'https://www.example.com',
49
60
  // Keep your existing settings (output, adapter, ...) as they are.
50
61
  integrations: [
51
62
  react(),
@@ -54,124 +65,116 @@ export default defineConfig({
54
65
  puckConfigPath: './src/puck.config.tsx',
55
66
  layout: './src/layouts/Layout.astro',
56
67
  }),
57
- conlocaCloud({
58
- endpoint: 'https://cms.example.com',
59
- puckConfigPath: './src/puck.config.tsx',
60
- publicBaseUrl: 'https://www.example.com',
61
- previewBuild: false,
62
- }),
68
+ conlocaCloud({ repoUri: 'your-org/your-site' }),
63
69
  ],
64
70
  });
65
71
  ```
66
72
 
73
+ - `conlocaCloud()` needs no options. It takes `puckConfigPath` and `siteStyles` from `conlocaCMS`, and builds for the
74
+ workspace editor at `https://app.conloca.com` (`endpoint`'s default).
75
+ - `connect` writes `repoUri` when the checkout's `origin` is on GitHub, so the editor page names its repository even
76
+ where the build has no git remote. Without it, the build reads the repository from GitHub Actions, Vercel or GitLab,
77
+ else from the checkout's `remote.origin.url`.
67
78
  - `conlocaCloud` is an add-on to `conlocaCMS`, not a replacement: keep both, with `react()` first. Doctor reports a
68
79
  config without `conlocaCMS` as an error.
69
- - `endpoint` is only the scheme and host of the address you open the editor at, such as `https://cms.example.com`. Leave
70
- out any path the browser's address bar shows after the host, and the trailing slash.
71
- - `puckConfigPath` is the value you already gave `conlocaCMS`. If your `conlocaCMS` options also set `siteStyles` or
72
- `fragmentPreviewRoute`, give `conlocaCloud` the same values, so the editor renders your pages with your site's styles.
73
- - `publicBaseUrl` is the address your deployed site is served from: the editor loads this build's editor files from
74
- there. The integration does **not** read Astro's `site` option, so set `publicBaseUrl` even when `site` holds the same
75
- address. Its only fallback is `CF_PAGES_URL`, which Cloudflare Pages sets when it runs the build itself. Without
76
- either, the build succeeds but does not register, and the editor never updates.
77
- - `previewBuild: false` keeps off the second build, the one that serves draft previews. Draft previews on your own
78
- deployment are not available yet, so keep this line: without it, every build that registers also runs that second
79
- build, which fails on a static site that has no SSR adapter.
80
-
81
- ### 3. Give the build a token
82
-
83
- In the editor at `endpoint`, open the account menu (the round button with your initial), choose **Workspace settings**,
84
- and go to **Build token**. The **Connect this site** screen of a site that has no build yet shows the same section.
85
- Choose **Create build token**. The token is shown once, as the line `CONLOCA_BUILD_TOKEN=cbt_…`, and **Copy environment
86
- variable** copies that whole line. Store it wherever `astro build` runs:
87
-
88
- - Where the name and the value are separate fields — a GitHub Actions secret, a Cloudflare Pages variable, most hosts'
89
- settings — the name is `CONLOCA_BUILD_TOKEN` and the value is **only** the part after `CONLOCA_BUILD_TOKEN=`, starting
90
- with `cbt_`. Do not paste the whole copied line as the value.
91
- - Where the input takes `NAME=value` lines, like a `.env` file, paste the whole line.
92
-
93
- Give the secret only to the steps that need it: `conloca doctor` and the build (see the
94
- [CI example](#ci-example-github-actions)), not to install scripts or deploy actions. Never write it into the config:
95
- doctor warns when `buildToken` is committed.
96
-
97
- One token serves the whole workspace. **Replace build token** creates a new one, and the old one stops working at once,
98
- so update every place that holds it.
99
-
100
- No Conloca-specific GitHub Action or OIDC setup is required. GitHub Actions, Vercel and GitLab provide the repository
101
- automatically; elsewhere the integration reads the checkout's `remote.origin.url`. Use `repoUri` only for a checkout
102
- where neither is available.
103
-
104
- A build without the token still succeeds; it only skips registration (see
105
- [When registration is skipped](#when-registration-is-skipped)). Once your CI is wired, set `requireRegistration: true`
106
- so a deploy can never silently leave the editor behind.
107
-
108
- ### 4. Push, then build
109
-
110
- A build registers the exact commit it was built from, and the endpoint refuses a commit it has not received from GitHub
111
- yet. Push first, then build the pushed commit; a CI build that starts on push does this for you. A build of a commit the
112
- endpoint does not have retries for about two and a half minutes and then fails with an error that says the commit
113
- `is not ingested`. A local `astro build` of an unpushed commit with the token set fails the same way.
114
-
115
- If you also build pull requests on GitHub Actions, give `actions/checkout` the pull request's own commit
116
- (`ref: ${{ github.event.pull_request.head.sha || github.sha }}`). By default it checks out a merge commit that GitHub
117
- makes for the pull request and never pushes, so the endpoint never receives it and the registration fails.
118
-
119
- A pull-request build deployed somewhere other than `publicBaseUrl`, such as a host's preview deploy, must set
120
- `publicBaseUrl` to the address that build is served from, for example from your host's deploy-URL variable (a full
121
- `https://` address). The editor on that branch loads the build's editor files from `publicBaseUrl`, and your production
122
- site does not serve the files only a pull request's build produced, so the editor would report that the bundle could not
123
- be loaded or verified.
124
-
125
- ### 5. Deploy, and serve `/_conloca/*` cross-origin
126
-
127
- The build writes the editor files under `_conloca/` in its output: `dist/_conloca/` for a static site, or the client
128
- folder such as `dist/client/_conloca/` for a server-rendered one. Deploy the build the way you already do, to the
129
- `publicBaseUrl` address.
130
-
131
- The editor runs on another origin and fetches those files from your site, so every `/_conloca/*` response must be public
132
- and carry `Access-Control-Allow-Origin: *`. Without the header the editor reports that this build's editor bundle could
133
- not be loaded or verified, and rebuilding does not help.
134
-
135
- The build writes that rule to a `_headers` file next to `_conloca/` (`dist/_headers`, or `dist/client/_headers` for a
136
- server-rendered site): one rule for `/_conloca/*`, plus one for each folder of fonts and images your site styles
137
- reference.
138
-
139
- - **Cloudflare Pages and Netlify** apply `_headers` themselves. Nothing else to do.
140
- - **Everywhere else**, `_headers` is ignored — including a Node server built with `@astrojs/node`, which has no setting
141
- for headers on static files. Set the header for every path the generated `_headers` lists, in whatever serves the
142
- site. A site made by `conloca create` is such a Node server: add the header in a proxy in front of it, or switch the
143
- site to static output (remove `output: 'server'` and the adapter from `astro.config.mjs`) and deploy it to Cloudflare
144
- Pages or Netlify. With Caddy in front of the Node server:
145
-
146
- ```caddyfile
147
- www.example.com {
148
- header /_conloca/* Access-Control-Allow-Origin *
149
- reverse_proxy localhost:4321
150
- }
80
+ - Nothing changes `output` or adds an adapter: a static site stays static.
81
+
82
+ By hand: on a site without `conlocaCMS`, run `npx @conloca/cli astro setup` first. Then
83
+ `bun add @conloca/astro-cms @conloca/cloud-astro` (plus the React peers), add `conlocaCloud()` right after
84
+ `conlocaCMS(...)`, and follow steps 2 and 3. `@conloca/cloud-astro` needs Astro 7.3.1 or a later 7.x release, and
85
+ `@conloca/astro-cms` at its own version: the `@conloca/*` packages are released together, so keep them on one version
86
+ and update them together.
87
+
88
+ ### 2. Your site's host in `sites.json`
89
+
90
+ The workspace editor opens `https://<host><base>_conloca/editor/`. `<host>` is `domains[defaultLocale]` of the site
91
+ named `default` in `sites.json` (or of the only site), and `<base>` is that site's `base`, `/` when unset:
92
+
93
+ ```json
94
+ "default": {
95
+ "locales": ["en"],
96
+ "defaultLocale": "en",
97
+ "domains": { "en": "www.example.com" }
98
+ }
99
+ ```
100
+
101
+ - `connect` writes `domains` from Astro's `site`, and `base` from Astro's `base` when it is not `/`. When `astro.config`
102
+ sets no plain `site`, pass the address: `npx @conloca/cli connect --site-url https://www.example.com`. `connect` never
103
+ writes Astro's `site` itself, since that changes canonical URLs and sitemaps.
104
+ - The host is a bare host such as `www.example.com`: no scheme, port or path. The editor never opens an IP address,
105
+ `localhost` or a host under `conloca.com`.
106
+ - Use the address visitors reach. A deploy that asks visitors to sign in, such as a Vercel preview behind Deployment
107
+ Protection, cannot be opened by the editor.
108
+
109
+ ### 3. Framing headers, only if your site forbids framing
110
+
111
+ The workspace editor shows `/_conloca/editor/` in a frame. A site that sends no `X-Frame-Options` and no
112
+ `frame-ancestors` can already be framed, so there is nothing to do; GitHub Pages sends neither. When a committed
113
+ `public/_headers`, `netlify.toml` or `vercel.json` sets one of them for the whole site, `connect` adds a rule for
114
+ `/_conloca/editor/`, and until one exists the build warns and `conloca doctor` reports CC10. The rules:
115
+
116
+ - **Cloudflare Pages and Cloudflare Workers static assets**, in `public/_headers` after any site-wide `/*` rule:
117
+
118
+ ```plain
119
+ /_conloca/editor/*
120
+ ! X-Frame-Options
121
+ ! Content-Security-Policy
122
+ Content-Security-Policy: frame-ancestors 'self' https://*.conloca.com
123
+
124
+ /_conloca/editor/sandbox-frame.html
125
+ Content-Security-Policy: sandbox allow-scripts
151
126
  ```
152
127
 
153
- With nginx in front of it:
128
+ `! Name` removes a header an earlier rule set. The site's own policy has to come off this path: two policies are both
129
+ enforced, and the editor page carries its own.
130
+
131
+ - **Netlify**, in `public/_headers`. Netlify cannot remove a header, so the rule only adds the policy; a site-wide
132
+ `X-Frame-Options` is then ignored by browsers, because `frame-ancestors` wins:
154
133
 
155
- ```nginx
156
- location /_conloca/ {
157
- add_header Access-Control-Allow-Origin * always;
158
- proxy_pass http://127.0.0.1:4321;
159
- }
134
+ ```plain
135
+ /_conloca/editor/*
136
+ Content-Security-Policy: frame-ancestors 'self' https://*.conloca.com
137
+
138
+ /_conloca/editor/sandbox-frame.html
139
+ Content-Security-Policy: sandbox allow-scripts
160
140
  ```
161
141
 
162
- If nginx serves the files itself, keep your `root` or `try_files` lines in that `location` instead of `proxy_pass`. A
163
- `location` with its own `add_header` drops the ones it would inherit from the `server` block, so repeat any you rely
164
- on.
142
+ - **Vercel**, in the `headers` list of `vercel.json`:
143
+
144
+ ```json
145
+ [
146
+ {
147
+ "source": "/_conloca/editor/:path*",
148
+ "headers": [{ "key": "Content-Security-Policy", "value": "frame-ancestors 'self' https://*.conloca.com" }]
149
+ },
150
+ {
151
+ "source": "/_conloca/editor/sandbox-frame.html",
152
+ "headers": [{ "key": "Content-Security-Policy", "value": "sandbox allow-scripts" }]
153
+ }
154
+ ]
155
+ ```
165
156
 
166
- Check it after the deploy, with the file name from the build log line
167
- `editor bundle written: /_conloca/editor-bundle.<hash>.js`:
157
+ - **A site-wide `Content-Security-Policy` with `frame-ancestors`**, on any host: a second policy cannot loosen it.
158
+ Narrow it yourself so it does not cover `/_conloca/editor/`, then add the rule above. `connect` reports this case
159
+ instead of editing a policy.
160
+ - **Headers set in host settings or by a server**, such as a proxy in front of an `@astrojs/node` server: exempt
161
+ `/_conloca/editor/` there the same way. `connect` cannot see them; `conloca doctor --live` reads the deployed page's
162
+ real headers (CC12).
168
163
 
169
- ```sh
170
- curl -sI -H 'Origin: https://cms.example.com' https://www.example.com/_conloca/editor-bundle.<hash>.js
171
- ```
164
+ ### 4. Commit, push and deploy
165
+
166
+ `connect` never commits, pushes or deploys. Commit its changes, push to the default branch, and deploy the way you
167
+ always do. The build writes the editor page under `_conloca/editor/` in its output (`dist/_conloca/editor/` for a static
168
+ site, the client folder such as `dist/client/_conloca/editor/` for a server-rendered one) and logs
169
+ `editor page written: /_conloca/editor/`. It needs no secret and no environment variable.
172
170
 
173
- The answer must be `200` and include `access-control-allow-origin: *`. `conloca doctor --live` checks that the file is
174
- deployed, not this header.
171
+ On the default branch the workspace editor uses the components of the default branch's deploy. On any other branch it
172
+ uses the deploy whose code is closest to the branch's latest commit, among the branch's own deploys, the default
173
+ branch's and a build of the branch it was created from (on a tie, in that order), and the editor says which; see
174
+ [Branch deploys](#branch-deploys).
175
+
176
+ `/_conloca/editor/conloca.json` publishes the repository's name and the build's branch and commit. If the repository is
177
+ not public, its name becomes public with the deploy.
175
178
 
176
179
  ### CI example (GitHub Actions)
177
180
 
@@ -190,75 +193,140 @@ jobs:
190
193
  - uses: actions/checkout@v4
191
194
  - uses: oven-sh/setup-bun@v2
192
195
  - run: bun install --frozen-lockfile
193
- # The token goes to doctor and the build only, not to install scripts or the deploy.
194
196
  - run: bunx @conloca/cli doctor
195
- env:
196
- CONLOCA_BUILD_TOKEN: ${{ secrets.CONLOCA_BUILD_TOKEN }}
197
197
  - run: bun run build
198
- env:
199
- CONLOCA_BUILD_TOKEN: ${{ secrets.CONLOCA_BUILD_TOKEN }}
200
198
  # Deploy the build the way you already do.
201
199
  ```
202
200
 
201
+ ### Branch deploys
202
+
203
+ On a branch other than the default one, the editor looks for that branch's own build: through the host's records on
204
+ GitHub (deployments, commit statuses, Cloudflare check runs) or its branch address. The deploy must be public for the
205
+ editor to frame it. Reading the records needs Conloca's GitHub App to have **Deployments**, **Commit statuses** and
206
+ **Checks** read access; an organization owner accepts that update on GitHub. Until then only the records go unread: a
207
+ Cloudflare Pages branch address still works. When no build of the branch is found, the editor uses an earlier build from
208
+ the branch's history (labelled as such), else the default branch's deploy, and says so.
209
+
210
+ | Host | Works when | By default | Found through |
211
+ | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- |
212
+ | Cloudflare Pages | previews public (Access off) and branch builds not excluded | **works** | check-run summary (needs permissions) or branch address (no permission) |
213
+ | Netlify | an open pull request from the same repository; previews public | PR deploy previews only, through commit statuses (needs permissions). Branch deploys are off; credit-based plans can make previews private | commit statuses (needs permissions) |
214
+ | Vercel | Deployment Protection off for previews | **protected**: the editor uses the default branch's deploy. Protection has been on by default since 2023-11 | Deployment (needs permissions) |
215
+ | Cloudflare Workers Builds | previews enabled, an open pull request from the same repository, preview URL on Cloudflare's own preview domain | PR only | bot PR comment (needs permissions) |
216
+ | Render | PR previews enabled | off (manual trigger by default) | Deployment created by a person (needs permissions) |
217
+ | S3, your own server or other static hosting with a public address per branch | an opt-in Actions job that posts a Deployment **on push**, for the built commit | the default branch's deploy | Deployment by `github-actions` |
218
+ | GitHub Pages (no per-branch deploys), Amplify, Cloudflare Workers Previews on custom domains | — | the default branch's deploy | not supported |
219
+
220
+ **Cloudflare Pages not connected to a Git repository** (`wrangler pages deploy`): set `CONLOCA_PAGES_PROJECT` to the
221
+ first label of the site's `pages.dev` address (`my-site-4k2` for `my-site-4k2.pages.dev`) in the production build's
222
+ environment, so branch addresses are found. Use the address label, not the project name you gave `wrangler`: when that
223
+ name is taken, Cloudflare adds a suffix to the address, and setting the project name then silently finds no branch
224
+ address.
225
+
226
+ When two branch names clean up to the same Cloudflare Pages branch address, Pages gives the second one a random suffix.
227
+ The editor can't predict that address, so that branch shows the default branch's components unless its deploy is also
228
+ reported to GitHub (the Deployment step below).
229
+
230
+ **Vercel:** Deployment Protection has been on for previews by default since 2023-11. Turn it off for previews to let the
231
+ editor frame them, knowing that anyone with a preview URL can then see it.
232
+
233
+ **Any other host:** the editor frames a branch build at its own address with the site's production base, so a preview
234
+ under a subpath of one site can't work. Publish each branch build at its own public address (a second host or bucket
235
+ works), then add a step that posts a GitHub Deployment for the built commit, on `push`, with `GITHUB_TOKEN` and no other
236
+ secret:
237
+
238
+ ```yaml
239
+ on: push
240
+ permissions:
241
+ contents: read
242
+ deployments: write
243
+ jobs:
244
+ deploy:
245
+ runs-on: ubuntu-latest
246
+ steps:
247
+ # … your build and deploy steps; the step with id `deploy` outputs `url` (https)
248
+ - uses: actions/github-script@v7
249
+ env:
250
+ PREVIEW_URL: ${{ steps.deploy.outputs.url }}
251
+ with:
252
+ script: |
253
+ const { owner, repo } = context.repo;
254
+ const { data } = await github.rest.repos.createDeployment({
255
+ owner, repo, ref: context.sha, environment: `preview/${context.ref_name}`,
256
+ auto_merge: false, required_contexts: [],
257
+ });
258
+ await github.rest.repos.createDeploymentStatus({
259
+ owner, repo, deployment_id: data.id, state: 'success', environment_url: process.env.PREVIEW_URL,
260
+ });
261
+ ```
262
+
263
+ A `pull_request` build checks out a merge commit, which never matches the branch's commit: build on `push`, or check out
264
+ `github.event.pull_request.head.sha` and pass that commit as `ref` instead of `context.sha`.
265
+
203
266
  ### Check it
204
267
 
205
- After the deploy finishes, run this in your repository, on the branch you built:
268
+ After the deploy finishes, run this in your repository:
206
269
 
207
270
  ```sh
208
- CONLOCA_BUILD_TOKEN=cbt_... bunx @conloca/cli doctor --live
271
+ npx @conloca/cli doctor --live
209
272
  ```
210
273
 
211
- `--live` asks the endpoint what it knows about this repository: whether it accepts the token, which commit registered
212
- the editor for this branch and site and which version of this package built it, and whether that editor bundle is still
213
- deployed. The token goes only to the `endpoint` in your config. If you did not keep a copy of the token, skip this step
214
- rather than replacing the token (that stops the CI secret working at once); reloading the editor is enough.
274
+ `--live` reads the deployed `<host><base>_conloca/editor/conloca.json` and the page's headers, and the protocol range
275
+ the editor publishes at `https://app.conloca.com/host/protocols.json`, and judges them by the same rules the workspace
276
+ editor applies. It sends no credential, so it runs anywhere, pull requests from forks included.
215
277
 
216
- Then reload the editor: it opens your site instead of **Connect this site**, and the **Build registration** row under
217
- **Workspace settings → Build token** turns from **Waiting for Astro build** to **Connected**.
278
+ Then open your workspace editor at `<slug>.conloca.com`. Until the editor page is live, **Connect this site** lists the
279
+ steps the site still needs: each row says what is done, whom it waits on, or what failed and how to fix it.
218
280
 
219
281
  ### Troubleshooting
220
282
 
221
- - **The build log ends with `editor at … NOT updated by this build`.** Prerequisites were missing, and each `missing:`
222
- line names one: `public base URL` means `publicBaseUrl` is not set (step 2), `build token` means the
223
- `CONLOCA_BUILD_TOKEN` secret does not reach the build (step 3). See
224
- [When registration is skipped](#when-registration-is-skipped).
225
- - **Doctor says the build token value starts with `"CONLOCA_BUILD_TOKEN="`, or the build fails with
226
- `registration rejected: HTTP 401` and the secret holds the whole copied line.** Change the value to the part starting
227
- with `cbt_` and rebuild. The token itself is fine; you do not need a new one.
228
- - **`registration rejected: HTTP 401` with a `cbt_…` value.** The token was replaced, which invalidates the old one at
229
- once. Put the new token in the `CONLOCA_BUILD_TOKEN` secret everywhere the site builds, then rebuild.
230
- - **The build fails with an error that says the commit `is not ingested`.** It built a commit the endpoint has not
231
- received. Push the commit, then rebuild (step 4).
232
- - **`registration rejected: HTTP 403` saying the repository is not covered by the workspace's GitHub installation.** Add
233
- the repository to that installation in your GitHub settings, then rebuild.
234
- - **The build log shows `registration complete`, but the editor still shows Connect this site.** Wait for the deploy to
235
- finish, then reload the editor.
236
- - **The editor says the editor bundle could not be loaded or verified.** `/_conloca/*` lacks the cross-origin header,
237
- `publicBaseUrl` does not serve this build's files, or the deploy has not finished (step 5).
283
+ Doctor names each check; the checklist in the workspace editor reports the same causes.
284
+
285
+ - **`sites.json` has no `domains` for the default locale, or not a bare host** (CC9). Run `connect`, or add your site's
286
+ host there (step 2). A host under `conloca.com`, an IP address or `localhost` is refused.
287
+ - **A committed header file sets `X-Frame-Options` or `frame-ancestors` for the whole site** (CC10). Run `connect`, or
288
+ add the rule from step 3.
289
+ - **The address cannot be reached, or answers 5xx or 429** (CC11). The site is down or limiting requests: check that it
290
+ is deployed and serving, then try again later.
291
+ - **`conloca.json` is not deployed** (CC11). The address answers 404 or an HTML page: deploy the commit that adds
292
+ `conlocaCloud()`, and check that `domains` names the address it is deployed to.
293
+ - **The address asks visitors to sign in** (CC11), for example Vercel Deployment Protection. Put the public production
294
+ address in `sites.json`, or let visitors through.
295
+ - **The page names no repository** (CC11). The build could not read the git remote: set `repoUri` in `conlocaCloud(...)`
296
+ (`connect` writes it from a checkout with a GitHub `origin`).
297
+ - **The address serves another repository's editor page, or another site** (CC11). Check `domains` and `siteId` in
298
+ `sites.json`.
299
+ - **`conloca.json` is not one the editor can read** (CC11). The host changed the built file; serve it unchanged.
300
+ - **The page is serving an older commit than your checkout** (CC11, a warning). Deploy to see your latest components.
301
+ - **The deployed page sends `X-Frame-Options`, or a `frame-ancestors` that leaves out `https://*.conloca.com`** (CC12).
302
+ Run `connect` again, or exempt `/_conloca/editor/` in your host settings (step 3).
303
+ - **The deployed page sends a `script-src` that does not allow `https://app.conloca.com`** (CC12). The page cannot load
304
+ the editor, and the workspace editor stops waiting for it. Detach the site's policy on `/_conloca/editor/` (step 3),
305
+ or add `https://app.conloca.com` to its `script-src` there.
306
+ - **The page's protocol is outside the range the editor speaks** (CC13). Rebuild with a newer `@conloca/cloud-astro` and
307
+ deploy; if the page is newer than the editor, the editor does not speak that version yet.
308
+ - **A workflow or the config still names `CONLOCA_BUILD_TOKEN`, `buildToken`, `publicBaseUrl`, `previewDomain` or
309
+ `requireRegistration`** (CC14). The editor page needs none of them: remove those lines. `connect` removes the workflow
310
+ lines that only pass the key.
238
311
 
239
312
  ## Options
240
313
 
241
- | Name | Required | Description |
242
- | ---------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
243
- | `endpoint` | yes | Editor endpoint, scheme and host only, e.g. `https://cms.example.com`: no path, no trailing slash. URL-shape validated. |
244
- | `puckConfigPath` | yes | Puck config entry to compile (same option name and value as in `@conloca/astro-cms`). |
245
- | `publicBaseUrl` | no | Where the deployed site is served; the editor loads the bundle from there. Astro's `site` is not read. Falls back to `CF_PAGES_URL`. |
246
- | `repoUri` | no | Advanced `owner/repo` override; normally detected from CI or the Git remote. |
247
- | `siteId` | no | Advanced site-id override for CMS-less builds; sites.json is authoritative. |
248
- | `buildToken` | no | Build token issued by the endpoint; use the `CONLOCA_BUILD_TOKEN` environment variable instead, so it is never committed. |
249
- | `siteStyles` | no | Site CSS compiled into the canvas stylesheet, as in `conlocaCMS`. |
250
- | `editorBundlePlugins` | no | esbuild plugins for the editor bundle, which is built outside Vite: pass e.g. the Typia transform your page schemas need. |
251
- | `fragmentPreviewRoute` | no | Content route for build-time style discovery, as in `conlocaCMS`. |
252
- | `previewDomain` | no | Dedicated preview domain. When set, switches to `preview-domain` mode and is used instead of `publicBaseUrl`. |
253
- | `previewBuild` | no | `PreviewBuildOptions` or `false`. On by default; set `false`, since draft previews on your own deployment are not available yet. |
254
- | `saasIssuer` | no | Draft previews only. JWT `iss` the preview middleware pins (the endpoint's token issuer). Baked in; else set at runtime. |
255
- | `requireRegistration` | no | Fail the build when registration is skipped for a missing prerequisite. Recommended in CI once setup is done. |
256
-
257
- The `conlocaCMS` options `schemasPath` and `mdxComponentFolders` reach the editor at `endpoint` automatically: the CMS
258
- publishes what it resolved and this integration compiles the schemas and the discovered MDX components into the editor
259
- bundle each build registers. The `conlocaCMS` options `editorStyles` and `editorCSS` have no effect on the editor at
260
- `endpoint` (they configure the local dev editor only); `templates` and the `routing` data bindings reach it through the
261
- same channel as `schemasPath`.
314
+ | Name | Required | Description |
315
+ | ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
316
+ | `endpoint` | no | The workspace editor's address, scheme and host only, no trailing slash; its host must start with `app.`. Defaults to `https://app.conloca.com`. |
317
+ | `puckConfigPath` | no | Puck config entry to compile. Defaults to the value `conlocaCMS` was given. |
318
+ | `repoUri` | no | Advanced `owner/repo` override; normally detected from CI or the Git remote. |
319
+ | `siteId` | no | Advanced site-id override for CMS-less builds; sites.json is authoritative. |
320
+ | `siteStyles` | no | Site CSS compiled into the canvas stylesheet, as in `conlocaCMS`. |
321
+ | `previewBuild` | no | `PreviewBuildOptions` or `false`. Off unless given as an object; refused under `@astrojs/vercel` and `@astrojs/netlify`. |
322
+ | `saasIssuer` | no | Draft previews only. JWT `iss` the preview middleware pins (the endpoint's token issuer). Baked in; else set at runtime. |
323
+
324
+ The `conlocaCMS` options `schemasPath`, `mdxComponentFolders`, `templates`, the `routing` data bindings, `editorStyles`
325
+ and `editorCSS` reach the editor page automatically: the CMS publishes what it resolved, and the editor page renders
326
+ your pages with them as the local editor at `/__cms` does.
327
+
328
+ `buildToken`, `requireRegistration`, `publicBaseUrl`, `previewDomain`, `editorBundlePlugins` and `fragmentPreviewRoute`
329
+ were removed: a config that still names one fails at load. Run `npx @conloca/cli connect` to update it.
262
330
 
263
331
  ## Public render path
264
332
 
@@ -271,40 +339,25 @@ they did before.
271
339
  Draft previews on your own deployment are not available yet. Keep `previewBuild: false` in your config: the preview
272
340
  build stays off, and a build produces only your normal site.
273
341
 
274
- ## When registration is skipped
275
-
276
- A build that lacks a prerequisite — no `CONLOCA_BUILD_TOKEN`, no repository identity, no git sha/branch, or no public
277
- base URL — completes without registering and ends with one summary block, with a `missing:` line for each prerequisite
278
- it lacks:
279
-
280
- ```plain
281
- [@conloca/cloud-astro] editor at https://cms.example.com NOT updated by this build
282
- missing: build token (set buildToken or CONLOCA_BUILD_TOKEN)
283
- consequence: registration was skipped, so the editor keeps serving the previous build of this branch (or the default branch's, or nothing, if neither was ever registered)
284
- check: conloca doctor --live
285
- ```
286
-
287
- Set `requireRegistration: true` in CI to turn that into a build failure. An attempted registration that the endpoint
288
- rejects always fails the build; there is no switch for that.
289
-
290
342
  ## Doctor
291
343
 
292
344
  This package is a `conloca doctor` extension (`conloca.doctor` in package.json): `conloca doctor` in a project that
293
345
  depends on it runs this package's checks after the CMS ones, offline by default.
294
346
 
295
- | Check | What it verifies |
296
- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
297
- | CC1 | `conlocaCloud(...)` is wired next to `conlocaCMS(...)` (an absent `conlocaCMS` is an error) |
298
- | CC2 | A build token is available (`CONLOCA_BUILD_TOKEN`; missing = error under CI, info locally) and parses as `cbt_…`, with its own message for a pasted `CONLOCA_BUILD_TOKEN=` prefix (skipped when `conlocaCloud` is not called) |
299
- | CC3 | `endpoint` is a valid https URL (no trailing slash); `publicBaseUrl`/`previewDomain` when set, or `CF_PAGES_URL` under CI; skipped likewise |
300
- | CC4 | `conlocaCMS` options the endpoint's editor ignores (`editorStyles`, `editorCSS`) |
301
- | CC5 | `--live`: the endpoint accepts the token (a 401 means a replaced token — put the new one in the CI secret — or an endpoint without the status route) |
302
- | CC6 | `--live`: a registration serves this branch and site — own row, inherited from the default branch, or none |
303
- | CC7 | `--live`: the editor bundle the registration names is still deployed (catches a later deploy deleting it) and how stale it is; it does not check the cross-origin header |
304
- | CC8 | `previewBuild` is `false`, or the preview build has an SSR adapter (the project's own or `previewBuild.adapter`); a static project with neither is an error, because every build that registers would fail |
305
-
306
- `conloca doctor --live` sends the build token ONLY to the configured endpoint. When the config computes `endpoint` (for
307
- example from an environment variable), set `CONLOCA_ENDPOINT` so doctor can read it.
347
+ | Check | What it verifies |
348
+ | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
349
+ | CC1 | `conlocaCloud(...)` is wired next to `conlocaCMS(...)` (an absent `conlocaCMS` is an error); notes that the deployed `conloca.json` publishes the repository's name |
350
+ | CC8 | `previewBuild` is absent or `false`, or the preview build has an SSR adapter (the project's own or `previewBuild.adapter`); `previewBuild` on a static project with neither is an error: `astro build` fails |
351
+ | CC9 | `sites.json` gives the site named `default` (or the only site) a bare host in `domains[defaultLocale]` and a valid `base`; Astro's `site` and `base`, when the config shows them, agree (warnings) |
352
+ | CC10 | No committed `public/_headers`, `netlify.toml` or `vercel.json` sets `X-Frame-Options` or `frame-ancestors` for the whole site without a `/_conloca/editor/` rule; the error carries the rule to add |
353
+ | CC11 | `--live`: `<host><base>_conloca/editor/conloca.json` is deployed, public, and names this repository and site; warns when it serves another commit than your checkout |
354
+ | CC12 | `--live`: the deployed `/_conloca/editor/` may be framed by `https://*.conloca.com` and its `script-src` allows the editor's origin |
355
+ | CC13 | `--live`: the page's protocol is in the range the editor publishes at `/host/protocols.json` |
356
+ | CC14 | No tracked workflow and not the astro config still names `CONLOCA_BUILD_TOKEN`, `buildToken`, `publicBaseUrl`, `previewDomain` or `requireRegistration` (warnings) |
357
+
358
+ `conloca doctor --live` sends no credential: it contacts only your site's host and the editor's public
359
+ `/host/protocols.json`. When the config computes `endpoint` (for example from an environment variable), set
360
+ `CONLOCA_ENDPOINT` so doctor can read it.
308
361
 
309
362
  The integration also scaffolds a one-page agent skill at `.claude/skills/conloca-cloud/SKILL.md` — in the nearest
310
363
  `.claude/` directory between the Astro project and the git root — on any Astro command that loads the config (build,