@conloca/cloud-astro 0.2.2 → 0.2.4
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.
- package/README.md +378 -207
- package/dist/.build-inputs.json +69 -0
- package/dist/src/component-manifest.d.ts +5 -3
- package/dist/src/component-manifest.d.ts.map +1 -1
- package/dist/src/component-manifest.js +7 -7
- package/dist/src/component-manifest.js.map +1 -1
- package/dist/src/constants.d.ts +14 -13
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +14 -13
- package/dist/src/constants.js.map +1 -1
- package/dist/src/d3-build.d.ts +70 -0
- package/dist/src/d3-build.d.ts.map +1 -0
- package/dist/src/d3-build.js +272 -0
- package/dist/src/d3-build.js.map +1 -0
- package/dist/src/descriptors.d.ts +2 -2
- package/dist/src/descriptors.d.ts.map +1 -1
- package/dist/src/descriptors.js +4 -2
- package/dist/src/descriptors.js.map +1 -1
- package/dist/src/doctor/checks-address.d.ts +18 -0
- package/dist/src/doctor/checks-address.d.ts.map +1 -0
- package/dist/src/doctor/checks-address.js +163 -0
- package/dist/src/doctor/checks-address.js.map +1 -0
- package/dist/src/doctor/checks-live.d.ts +8 -5
- package/dist/src/doctor/checks-live.d.ts.map +1 -1
- package/dist/src/doctor/checks-live.js +226 -188
- package/dist/src/doctor/checks-live.js.map +1 -1
- package/dist/src/doctor/checks-offline.d.ts +6 -25
- package/dist/src/doctor/checks-offline.d.ts.map +1 -1
- package/dist/src/doctor/checks-offline.js +30 -259
- package/dist/src/doctor/checks-offline.js.map +1 -1
- package/dist/src/doctor/checks-preview-limits.d.ts +11 -0
- package/dist/src/doctor/checks-preview-limits.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview-limits.js +133 -0
- package/dist/src/doctor/checks-preview-limits.js.map +1 -0
- package/dist/src/doctor/checks-preview-live.d.ts +14 -0
- package/dist/src/doctor/checks-preview-live.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview-live.js +72 -0
- package/dist/src/doctor/checks-preview-live.js.map +1 -0
- package/dist/src/doctor/checks-preview.d.ts +7 -0
- package/dist/src/doctor/checks-preview.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview.js +287 -0
- package/dist/src/doctor/checks-preview.js.map +1 -0
- package/dist/src/doctor/config-scan.d.ts +12 -3
- package/dist/src/doctor/config-scan.d.ts.map +1 -1
- package/dist/src/doctor/config-scan.js +38 -11
- package/dist/src/doctor/config-scan.js.map +1 -1
- package/dist/src/doctor/run.d.ts.map +1 -1
- package/dist/src/doctor/run.js +16 -10
- package/dist/src/doctor/run.js.map +1 -1
- package/dist/src/doctor/types.d.ts +17 -7
- package/dist/src/doctor/types.d.ts.map +1 -1
- package/dist/src/doctor/types.js +17 -7
- package/dist/src/doctor/types.js.map +1 -1
- package/dist/src/editor-page/bundle.d.ts +90 -0
- package/dist/src/editor-page/bundle.d.ts.map +1 -0
- package/dist/src/editor-page/bundle.js +373 -0
- package/dist/src/editor-page/bundle.js.map +1 -0
- package/dist/src/editor-page/data-schemas.d.ts +16 -0
- package/dist/src/editor-page/data-schemas.d.ts.map +1 -0
- package/dist/src/editor-page/data-schemas.js +39 -0
- package/dist/src/editor-page/data-schemas.js.map +1 -0
- package/dist/src/editor-page/emit.d.ts +69 -0
- package/dist/src/editor-page/emit.d.ts.map +1 -0
- package/dist/src/editor-page/emit.js +254 -0
- package/dist/src/editor-page/emit.js.map +1 -0
- package/dist/src/editor-page/framing.d.ts +23 -0
- package/dist/src/editor-page/framing.d.ts.map +1 -0
- package/dist/src/editor-page/framing.js +39 -0
- package/dist/src/editor-page/framing.js.map +1 -0
- package/dist/src/editor-page/page.d.ts +9 -0
- package/dist/src/editor-page/page.d.ts.map +1 -0
- package/dist/src/editor-page/page.js +31 -0
- package/dist/src/editor-page/page.js.map +1 -0
- package/dist/src/editor-page/site-base.d.ts +4 -0
- package/dist/src/editor-page/site-base.d.ts.map +1 -0
- package/dist/src/editor-page/site-base.js +13 -0
- package/dist/src/editor-page/site-base.js.map +1 -0
- package/dist/src/git.d.ts +11 -8
- package/dist/src/git.d.ts.map +1 -1
- package/dist/src/git.js +25 -8
- package/dist/src/git.js.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/integration.d.ts +1 -1
- package/dist/src/integration.d.ts.map +1 -1
- package/dist/src/integration.js +377 -416
- package/dist/src/integration.js.map +1 -1
- package/dist/src/node.d.ts +3 -1
- package/dist/src/node.d.ts.map +1 -1
- package/dist/src/node.js +7 -2
- package/dist/src/node.js.map +1 -1
- package/dist/src/preview/_dispatch.d.ts +12 -0
- package/dist/src/preview/_dispatch.d.ts.map +1 -1
- package/dist/src/preview/_dispatch.js +31 -0
- package/dist/src/preview/_dispatch.js.map +1 -1
- package/dist/src/preview/_resolve-opts.d.ts +19 -10
- package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
- package/dist/src/preview/_resolve-opts.js +24 -11
- package/dist/src/preview/_resolve-opts.js.map +1 -1
- package/dist/src/preview/banner.d.ts +12 -9
- package/dist/src/preview/banner.d.ts.map +1 -1
- package/dist/src/preview/banner.js +46 -43
- package/dist/src/preview/banner.js.map +1 -1
- package/dist/src/preview/cloudflare-adapter.d.ts +35 -0
- package/dist/src/preview/cloudflare-adapter.d.ts.map +1 -0
- package/dist/src/preview/cloudflare-adapter.js +92 -0
- package/dist/src/preview/cloudflare-adapter.js.map +1 -0
- package/dist/src/preview/cookie.d.ts +13 -14
- package/dist/src/preview/cookie.d.ts.map +1 -1
- package/dist/src/preview/cookie.js +19 -26
- package/dist/src/preview/cookie.js.map +1 -1
- package/dist/src/preview/dispatcher.d.ts +73 -0
- package/dist/src/preview/dispatcher.d.ts.map +1 -0
- package/dist/src/preview/dispatcher.js +329 -0
- package/dist/src/preview/dispatcher.js.map +1 -0
- package/dist/src/preview/entry-code.d.ts +33 -0
- package/dist/src/preview/entry-code.d.ts.map +1 -0
- package/dist/src/preview/entry-code.js +33 -0
- package/dist/src/preview/entry-code.js.map +1 -0
- package/dist/src/preview/headers.d.ts +24 -4
- package/dist/src/preview/headers.d.ts.map +1 -1
- package/dist/src/preview/headers.js +35 -7
- package/dist/src/preview/headers.js.map +1 -1
- package/dist/src/preview/label.d.ts +8 -0
- package/dist/src/preview/label.d.ts.map +1 -0
- package/dist/src/preview/label.js +14 -0
- package/dist/src/preview/label.js.map +1 -0
- package/dist/src/preview/landing.d.ts +23 -2
- package/dist/src/preview/landing.d.ts.map +1 -1
- package/dist/src/preview/landing.js +105 -37
- package/dist/src/preview/landing.js.map +1 -1
- package/dist/src/preview/middleware.d.ts +49 -22
- package/dist/src/preview/middleware.d.ts.map +1 -1
- package/dist/src/preview/middleware.js +259 -100
- package/dist/src/preview/middleware.js.map +1 -1
- package/dist/src/preview/preview-path.d.ts +47 -5
- package/dist/src/preview/preview-path.d.ts.map +1 -1
- package/dist/src/preview/preview-path.js +65 -8
- package/dist/src/preview/preview-path.js.map +1 -1
- package/dist/src/preview/redeem-url.d.ts +7 -0
- package/dist/src/preview/redeem-url.d.ts.map +1 -0
- package/dist/src/preview/redeem-url.js +14 -0
- package/dist/src/preview/redeem-url.js.map +1 -0
- package/dist/src/preview/site-middleware.d.ts +5 -5
- package/dist/src/preview/site-middleware.d.ts.map +1 -1
- package/dist/src/preview/site-middleware.js +53 -26
- package/dist/src/preview/site-middleware.js.map +1 -1
- package/dist/src/preview-build.d.ts +29 -15
- package/dist/src/preview-build.d.ts.map +1 -1
- package/dist/src/preview-build.js +66 -25
- package/dist/src/preview-build.js.map +1 -1
- package/dist/src/preview.d.ts +1 -1
- package/dist/src/preview.d.ts.map +1 -1
- package/dist/src/preview.js +1 -1
- package/dist/src/preview.js.map +1 -1
- package/dist/src/repository.d.ts +1 -1
- package/dist/src/repository.js +1 -1
- package/dist/src/resolve-options.d.ts +17 -0
- package/dist/src/resolve-options.d.ts.map +1 -0
- package/dist/src/resolve-options.js +21 -0
- package/dist/src/resolve-options.js.map +1 -0
- package/dist/src/site-id.d.ts +0 -2
- package/dist/src/site-id.d.ts.map +1 -1
- package/dist/src/site-id.js +2 -3
- package/dist/src/site-id.js.map +1 -1
- package/dist/src/skill.d.ts +11 -0
- package/dist/src/skill.d.ts.map +1 -1
- package/dist/src/skill.js +32 -9
- package/dist/src/skill.js.map +1 -1
- package/dist/src/types.d.ts +33 -78
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +63 -13
- package/src/component-manifest.ts +11 -8
- package/src/constants.ts +15 -13
- package/src/d3-build.ts +315 -0
- package/src/descriptors.ts +6 -4
- package/src/doctor/checks-address.ts +190 -0
- package/src/doctor/checks-live.ts +262 -268
- package/src/doctor/checks-offline.ts +32 -279
- package/src/doctor/checks-preview-limits.ts +137 -0
- package/src/doctor/checks-preview-live.ts +77 -0
- package/src/doctor/checks-preview.ts +302 -0
- package/src/doctor/config-scan.ts +35 -9
- package/src/doctor/run.ts +18 -16
- package/src/doctor/types.ts +17 -7
- package/src/editor-page/bundle.ts +487 -0
- package/src/editor-page/data-schemas.ts +47 -0
- package/src/editor-page/emit.ts +362 -0
- package/src/editor-page/framing.ts +62 -0
- package/src/editor-page/page.ts +37 -0
- package/src/editor-page/site-base.ts +11 -0
- package/src/git.ts +29 -10
- package/src/index.ts +22 -6
- package/src/integration.ts +399 -469
- package/src/node.ts +18 -2
- package/src/preview/_dispatch.ts +36 -1
- package/src/preview/_resolve-opts.ts +35 -12
- package/src/preview/banner.ts +61 -43
- package/src/preview/cloudflare-adapter.ts +103 -0
- package/src/preview/cookie.ts +18 -24
- package/src/preview/dispatcher.ts +407 -0
- package/src/preview/entry-code.ts +51 -0
- package/src/preview/headers.ts +35 -7
- package/src/preview/label.ts +12 -0
- package/src/preview/landing.ts +117 -39
- package/src/preview/middleware.ts +302 -115
- package/src/preview/preview-path.ts +83 -8
- package/src/preview/redeem-url.ts +14 -0
- package/src/preview/site-middleware.ts +60 -30
- package/src/preview-build.ts +85 -26
- package/src/preview-handler.astro +12 -9
- package/src/preview.ts +0 -1
- package/src/repository.ts +1 -1
- package/src/resolve-options.ts +37 -0
- package/src/site-id.ts +2 -4
- package/src/skill/SKILL.md +63 -55
- package/src/skill.ts +36 -8
- package/src/types.ts +33 -79
- package/src/virtual-modules.d.ts +4 -1
- package/dist/src/build-commit.d.ts +0 -19
- package/dist/src/build-commit.d.ts.map +0 -1
- package/dist/src/build-commit.js +0 -6
- package/dist/src/build-commit.js.map +0 -1
- package/dist/src/bundle.d.ts +0 -181
- package/dist/src/bundle.d.ts.map +0 -1
- package/dist/src/bundle.js +0 -413
- package/dist/src/bundle.js.map +0 -1
- package/dist/src/discovery.d.ts +0 -58
- package/dist/src/discovery.d.ts.map +0 -1
- package/dist/src/discovery.js +0 -133
- package/dist/src/discovery.js.map +0 -1
- package/dist/src/register.d.ts +0 -98
- package/dist/src/register.d.ts.map +0 -1
- package/dist/src/register.js +0 -103
- package/dist/src/register.js.map +0 -1
- package/src/build-commit.ts +0 -22
- package/src/bundle.ts +0 -570
- package/src/discovery.ts +0 -183
- package/src/register.ts +0 -180
package/README.md
CHANGED
|
@@ -1,42 +1,54 @@
|
|
|
1
1
|
# `@conloca/cloud-astro`
|
|
2
2
|
|
|
3
|
-
Astro integration that
|
|
4
|
-
to `conlocaCMS` to:
|
|
5
|
-
|
|
6
|
-
1.
|
|
7
|
-
(react/react-dom/jsx-runtime/`@puckeditor/core` stay external — the editor supplies them at runtime)
|
|
8
|
-
|
|
9
|
-
2.
|
|
10
|
-
|
|
11
|
-
|
|
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, build the preview server that renders drafts: next to a static site on
|
|
10
|
+
Cloudflare Workers (under `/_conloca/preview/<branch>/`), on the site's own server deploy, or as a separate deploy.
|
|
11
|
+
3. Wire preview middleware that admits only passes signed by the endpoint, for the repository, site and branch the
|
|
12
|
+
preview build was made from.
|
|
12
13
|
4. Expose `PreviewContentAPI` for `.astro` pages to fetch draft content.
|
|
14
|
+
5. Show share links: a viewer sees who shared the draft and when the link expires; an expired, turned-off, published or
|
|
15
|
+
discarded link shows its own page.
|
|
13
16
|
|
|
14
|
-
Items 2 to
|
|
15
|
-
with `previewBuild: false` (see [Draft previews](#draft-previews)).
|
|
17
|
+
Items 2 to 5 stay off unless `previewBuild` is given as an object (see [Draft previews](#draft-previews)).
|
|
16
18
|
|
|
17
19
|
## Setup
|
|
18
20
|
|
|
19
21
|
Before you start you need:
|
|
20
22
|
|
|
21
|
-
- An Astro site
|
|
22
|
-
- The repository connected to
|
|
23
|
-
GitHub**, and pick the repository on GitHub's installation screen. If a GitHub organization
|
|
24
|
-
you are not one of its owners, an owner has to approve the installation; until then the editor
|
|
25
|
-
approval**.
|
|
26
|
-
-
|
|
27
|
-
|
|
23
|
+
- An Astro site in a GitHub repository.
|
|
24
|
+
- The repository connected to your workspace editor at `<slug>.conloca.com`: sign in there with **Continue with
|
|
25
|
+
GitHub**, choose **Connect GitHub**, and pick the repository on GitHub's installation screen. If a GitHub organization
|
|
26
|
+
owns the repository and you are not one of its owners, an owner has to approve the installation; until then the editor
|
|
27
|
+
shows **Waiting for approval**.
|
|
28
|
+
- A place the site is deployed to, at an address visitors reach without signing in. The workspace editor edits the
|
|
29
|
+
deployed site: it opens the editor page your build adds under `/_conloca/editor/`, so editing starts after the first
|
|
30
|
+
deploy. For editing before that, `astro dev` keeps the local editor at `/__cms`.
|
|
28
31
|
|
|
29
|
-
### 1.
|
|
32
|
+
### 1. Run `conloca connect`
|
|
33
|
+
|
|
34
|
+
In the site's folder, or the repository holding it:
|
|
30
35
|
|
|
31
36
|
```sh
|
|
32
|
-
|
|
37
|
+
npx @conloca/cli connect
|
|
33
38
|
```
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
A coding agent can do the whole setup from one line:
|
|
41
|
+
`In my Astro site's folder, run npx @conloca/cli@<version> connect, then commit, push and deploy.`
|
|
42
|
+
|
|
43
|
+
`connect` adds `@conloca/astro-cms`, `@conloca/cloud-astro`, `@astrojs/react` and `@vitejs/plugin-react` with the
|
|
44
|
+
package manager of the nearest lockfile, wires `astro.config`, writes the site's host into `sites.json` (step 2), adds a
|
|
45
|
+
framing rule only where a committed header file forbids framing (step 3), builds the site once to check that the editor
|
|
46
|
+
page is there, and removes old build key lines from workflows. Every change is shown as a diff first: in a terminal it
|
|
47
|
+
asks once, `--yes` accepts without asking, and `--dry-run` writes nothing. A value you set yourself is kept and reported
|
|
48
|
+
as `differs`. It exits `2` with the lines to add when a step needs you, such as a config that is not a plain
|
|
49
|
+
`defineConfig({ integrations: [...] })`. `npx @conloca/cli connect --help` lists every option.
|
|
38
50
|
|
|
39
|
-
|
|
51
|
+
The config it wires:
|
|
40
52
|
|
|
41
53
|
```js
|
|
42
54
|
// astro.config.mjs
|
|
@@ -46,6 +58,7 @@ import { conlocaCloud } from '@conloca/cloud-astro';
|
|
|
46
58
|
import { defineConfig } from 'astro/config';
|
|
47
59
|
|
|
48
60
|
export default defineConfig({
|
|
61
|
+
site: 'https://www.example.com',
|
|
49
62
|
// Keep your existing settings (output, adapter, ...) as they are.
|
|
50
63
|
integrations: [
|
|
51
64
|
react(),
|
|
@@ -54,124 +67,127 @@ export default defineConfig({
|
|
|
54
67
|
puckConfigPath: './src/puck.config.tsx',
|
|
55
68
|
layout: './src/layouts/Layout.astro',
|
|
56
69
|
}),
|
|
57
|
-
conlocaCloud({
|
|
58
|
-
endpoint: 'https://cms.example.com',
|
|
59
|
-
puckConfigPath: './src/puck.config.tsx',
|
|
60
|
-
publicBaseUrl: 'https://www.example.com',
|
|
61
|
-
previewBuild: false,
|
|
62
|
-
}),
|
|
70
|
+
conlocaCloud({ repoUri: 'your-org/your-site' }),
|
|
63
71
|
],
|
|
64
72
|
});
|
|
65
73
|
```
|
|
66
74
|
|
|
75
|
+
- `conlocaCloud()` needs no options. It takes `puckConfigPath` and `siteStyles` from `conlocaCMS`, and builds for the
|
|
76
|
+
workspace editor at `https://app.conloca.com` (`endpoint`'s default).
|
|
77
|
+
- `connect` writes `repoUri` when the checkout's `origin` is on GitHub, so the editor page names its repository even
|
|
78
|
+
where the build has no git remote. Without it, the build reads the repository from GitHub Actions, Vercel or GitLab,
|
|
79
|
+
else from the checkout's `remote.origin.url`.
|
|
67
80
|
- `conlocaCloud` is an add-on to `conlocaCMS`, not a replacement: keep both, with `react()` first. Doctor reports a
|
|
68
81
|
config without `conlocaCMS` as an error.
|
|
69
|
-
- `
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
}
|
|
82
|
+
- Nothing changes `output` or adds an adapter: a static site stays static.
|
|
83
|
+
|
|
84
|
+
By hand: on a site without `conlocaCMS`, run `npx @conloca/cli astro setup` first. Then
|
|
85
|
+
`bun add @conloca/astro-cms @conloca/cloud-astro` (plus the React peers), add `conlocaCloud()` right after
|
|
86
|
+
`conlocaCMS(...)`, and follow steps 2 and 3. `@conloca/cloud-astro` needs Astro 7.3.1 or a later 7.x release, and a
|
|
87
|
+
matching `@conloca/astro-cms`: each `@conloca/*` package has its own version, so use `conloca upgrade` to move them to
|
|
88
|
+
the versions one CLI release pins.
|
|
89
|
+
|
|
90
|
+
### 2. Your site's host in `sites.json`
|
|
91
|
+
|
|
92
|
+
The workspace editor opens `https://<host><base>_conloca/editor/`. `<host>` is `domains[defaultLocale]` of the site
|
|
93
|
+
named `default` in `sites.json` (or of the only site), and `<base>` is that site's `base`, `/` when unset:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
"default": {
|
|
97
|
+
"locales": ["en"],
|
|
98
|
+
"defaultLocale": "en",
|
|
99
|
+
"domains": { "en": "www.example.com" }
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- `connect` writes `domains` from Astro's `site`, and `base` from Astro's `base` when it is not `/`. When `astro.config`
|
|
104
|
+
sets no plain `site`, pass the address: `npx @conloca/cli connect --site-url https://www.example.com`. `connect` never
|
|
105
|
+
writes Astro's `site` itself, since that changes canonical URLs and sitemaps.
|
|
106
|
+
- The host is a bare host such as `www.example.com`: no scheme, port or path. The editor never opens an IP address,
|
|
107
|
+
`localhost` or a host under `conloca.com`.
|
|
108
|
+
- Use the address visitors reach. A deploy that asks visitors to sign in, such as a Vercel preview behind Deployment
|
|
109
|
+
Protection, cannot be opened by the editor.
|
|
110
|
+
|
|
111
|
+
### 3. Framing headers, only if your site forbids framing
|
|
112
|
+
|
|
113
|
+
The workspace editor shows `/_conloca/editor/` in a frame. A site that sends no `X-Frame-Options` and no
|
|
114
|
+
`frame-ancestors` can already be framed, so there is nothing to do; GitHub Pages sends neither. When a committed
|
|
115
|
+
`public/_headers`, `netlify.toml` or `vercel.json` sets one of them for the whole site, `connect` adds a rule for
|
|
116
|
+
`/_conloca/editor/`, and until one exists the build warns and `conloca doctor` reports CC10. The rules:
|
|
117
|
+
|
|
118
|
+
- **Cloudflare Pages and Cloudflare Workers static assets**, in `public/_headers` after any site-wide `/*` rule:
|
|
119
|
+
|
|
120
|
+
```plain
|
|
121
|
+
/_conloca/editor/*
|
|
122
|
+
! X-Frame-Options
|
|
123
|
+
! Content-Security-Policy
|
|
124
|
+
Content-Security-Policy: frame-ancestors 'self' https://*.conloca.com
|
|
125
|
+
|
|
126
|
+
/_conloca/editor/sandbox-frame.html
|
|
127
|
+
Content-Security-Policy: sandbox allow-scripts
|
|
151
128
|
```
|
|
152
129
|
|
|
153
|
-
|
|
130
|
+
`! Name` removes a header an earlier rule set. The site's own policy has to come off this path: two policies are both
|
|
131
|
+
enforced, and the editor page carries its own.
|
|
132
|
+
|
|
133
|
+
- **Netlify**, in `public/_headers`. Netlify cannot remove a header, so the rule only adds the policy; a site-wide
|
|
134
|
+
`X-Frame-Options` is then ignored by browsers, because `frame-ancestors` wins:
|
|
135
|
+
|
|
136
|
+
```plain
|
|
137
|
+
/_conloca/editor/*
|
|
138
|
+
Content-Security-Policy: frame-ancestors 'self' https://*.conloca.com
|
|
139
|
+
|
|
140
|
+
/_conloca/editor/sandbox-frame.html
|
|
141
|
+
Content-Security-Policy: sandbox allow-scripts
|
|
142
|
+
```
|
|
154
143
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
144
|
+
- **Vercel**, in the `headers` list of `vercel.json`:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
[
|
|
148
|
+
{
|
|
149
|
+
"source": "/_conloca/editor/:path*",
|
|
150
|
+
"headers": [{ "key": "Content-Security-Policy", "value": "frame-ancestors 'self' https://*.conloca.com" }]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"source": "/_conloca/editor/sandbox-frame.html",
|
|
154
|
+
"headers": [{ "key": "Content-Security-Policy", "value": "sandbox allow-scripts" }]
|
|
155
|
+
}
|
|
156
|
+
]
|
|
160
157
|
```
|
|
161
158
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
- **A site-wide `Content-Security-Policy` with `frame-ancestors`**, on any host: a second policy cannot loosen it.
|
|
160
|
+
Narrow it yourself so it does not cover `/_conloca/editor/`, then add the rule above. `connect` reports this case
|
|
161
|
+
instead of editing a policy.
|
|
162
|
+
- **Headers set in host settings or by a server**, such as a proxy in front of an `@astrojs/node` server: exempt
|
|
163
|
+
`/_conloca/editor/` there the same way. `connect` cannot see them; `conloca doctor --live` reads the deployed page's
|
|
164
|
+
real headers (CC12).
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
`editor bundle written: /_conloca/editor-bundle.<hash>.js`:
|
|
166
|
+
### 4. Commit, push and deploy
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
`connect` never commits, pushes or deploys. Commit its changes, push to the default branch, and deploy the way you
|
|
169
|
+
always do. The build writes the editor page under `_conloca/editor/` in its output (`dist/_conloca/editor/` for a static
|
|
170
|
+
site, the client folder such as `dist/client/_conloca/editor/` for a server-rendered one) and logs
|
|
171
|
+
`editor page written: /_conloca/editor/`. It needs no secret and no environment variable.
|
|
172
|
+
|
|
173
|
+
On the default branch the workspace editor uses the components of the default branch's deploy. On any other branch it
|
|
174
|
+
uses the deploy whose code is closest to the branch's latest commit, among the branch's own deploys, the default
|
|
175
|
+
branch's and a build of the branch it was created from (on a tie, in that order), and the editor says which; see
|
|
176
|
+
[Branch deploys](#branch-deploys).
|
|
177
|
+
|
|
178
|
+
`/_conloca/editor/conloca.json` publishes the repository's name, the build's branch and commit, and whether the build
|
|
179
|
+
serves draft previews with the preview protocol it speaks (`preview`: `{ "mode": "d3", "protocol": 2 }` for a static
|
|
180
|
+
site with `previewBuild`, `d2` with an adapter, `d4` with `separate: true`, else `off`). If the repository is not
|
|
181
|
+
public, its name becomes public with the deploy. Protocol 2 opens a preview with a single-use `conloca_code` link that
|
|
182
|
+
the preview server trades for the pass with Conloca; a link that carries the pass itself (`conloca_preview`, protocol 1)
|
|
183
|
+
still opens in this release and stops opening in the next.
|
|
184
|
+
|
|
185
|
+
`conloca.json` also lists the build's prerendered page routes (`routes`, at most 500 and within 16 KiB for the whole
|
|
186
|
+
file), which the workspace editor offers when a site has no Conloca pages yet; they are public with the deploy, like the
|
|
187
|
+
pages themselves.
|
|
172
188
|
|
|
173
|
-
|
|
174
|
-
|
|
189
|
+
`/_conloca/editor/data-schemas.json` publishes the JSON schema of each `dataSchemas` collection, the metadata the
|
|
190
|
+
editor's entry forms already use, so agents can write data entries that match.
|
|
175
191
|
|
|
176
192
|
### CI example (GitHub Actions)
|
|
177
193
|
|
|
@@ -190,75 +206,140 @@ jobs:
|
|
|
190
206
|
- uses: actions/checkout@v4
|
|
191
207
|
- uses: oven-sh/setup-bun@v2
|
|
192
208
|
- run: bun install --frozen-lockfile
|
|
193
|
-
# The token goes to doctor and the build only, not to install scripts or the deploy.
|
|
194
209
|
- run: bunx @conloca/cli doctor
|
|
195
|
-
env:
|
|
196
|
-
CONLOCA_BUILD_TOKEN: ${{ secrets.CONLOCA_BUILD_TOKEN }}
|
|
197
210
|
- run: bun run build
|
|
198
|
-
env:
|
|
199
|
-
CONLOCA_BUILD_TOKEN: ${{ secrets.CONLOCA_BUILD_TOKEN }}
|
|
200
211
|
# Deploy the build the way you already do.
|
|
201
212
|
```
|
|
202
213
|
|
|
214
|
+
### Branch deploys
|
|
215
|
+
|
|
216
|
+
On a branch other than the default one, the editor looks for that branch's own build: through the host's records on
|
|
217
|
+
GitHub (deployments, commit statuses, Cloudflare check runs) or its branch address. The deploy must be public for the
|
|
218
|
+
editor to frame it. Reading the records needs Conloca's GitHub App to have **Deployments**, **Commit statuses** and
|
|
219
|
+
**Checks** read access; an organization owner accepts that update on GitHub. Until then only the records go unread: a
|
|
220
|
+
Cloudflare Pages branch address still works. When no build of the branch is found, the editor uses an earlier build from
|
|
221
|
+
the branch's history (labelled as such), else the default branch's deploy, and says so.
|
|
222
|
+
|
|
223
|
+
| Host | Works when | By default | Found through |
|
|
224
|
+
| -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- |
|
|
225
|
+
| Cloudflare Pages | previews public (Access off) and branch builds not excluded | **works** | check-run summary (needs permissions) or branch address (no permission) |
|
|
226
|
+
| 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) |
|
|
227
|
+
| 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) |
|
|
228
|
+
| 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) |
|
|
229
|
+
| Render | PR previews enabled | off (manual trigger by default) | Deployment created by a person (needs permissions) |
|
|
230
|
+
| 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` |
|
|
231
|
+
| GitHub Pages (no per-branch deploys), Amplify, Cloudflare Workers Previews on custom domains | — | the default branch's deploy | not supported |
|
|
232
|
+
|
|
233
|
+
**Cloudflare Pages not connected to a Git repository** (`wrangler pages deploy`): set `CONLOCA_PAGES_PROJECT` to the
|
|
234
|
+
first label of the site's `pages.dev` address (`my-site-4k2` for `my-site-4k2.pages.dev`) in the production build's
|
|
235
|
+
environment, so branch addresses are found. Use the address label, not the project name you gave `wrangler`: when that
|
|
236
|
+
name is taken, Cloudflare adds a suffix to the address, and setting the project name then silently finds no branch
|
|
237
|
+
address.
|
|
238
|
+
|
|
239
|
+
When two branch names clean up to the same Cloudflare Pages branch address, Pages gives the second one a random suffix.
|
|
240
|
+
The editor can't predict that address, so that branch shows the default branch's components unless its deploy is also
|
|
241
|
+
reported to GitHub (the Deployment step below).
|
|
242
|
+
|
|
243
|
+
**Vercel:** Deployment Protection has been on for previews by default since 2023-11. Turn it off for previews to let the
|
|
244
|
+
editor frame them, knowing that anyone with a preview URL can then see it.
|
|
245
|
+
|
|
246
|
+
**Any other host:** the editor frames a branch build at its own address with the site's production base, so a preview
|
|
247
|
+
under a subpath of one site can't work. Publish each branch build at its own public address (a second host or bucket
|
|
248
|
+
works), then add a step that posts a GitHub Deployment for the built commit, on `push`, with `GITHUB_TOKEN` and no other
|
|
249
|
+
secret:
|
|
250
|
+
|
|
251
|
+
```yaml
|
|
252
|
+
on: push
|
|
253
|
+
permissions:
|
|
254
|
+
contents: read
|
|
255
|
+
deployments: write
|
|
256
|
+
jobs:
|
|
257
|
+
deploy:
|
|
258
|
+
runs-on: ubuntu-latest
|
|
259
|
+
steps:
|
|
260
|
+
# … your build and deploy steps; the step with id `deploy` outputs `url` (https)
|
|
261
|
+
- uses: actions/github-script@v7
|
|
262
|
+
env:
|
|
263
|
+
PREVIEW_URL: ${{ steps.deploy.outputs.url }}
|
|
264
|
+
with:
|
|
265
|
+
script: |
|
|
266
|
+
const { owner, repo } = context.repo;
|
|
267
|
+
const { data } = await github.rest.repos.createDeployment({
|
|
268
|
+
owner, repo, ref: context.sha, environment: `preview/${context.ref_name}`,
|
|
269
|
+
auto_merge: false, required_contexts: [],
|
|
270
|
+
});
|
|
271
|
+
await github.rest.repos.createDeploymentStatus({
|
|
272
|
+
owner, repo, deployment_id: data.id, state: 'success', environment_url: process.env.PREVIEW_URL,
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
A `pull_request` build checks out a merge commit, which never matches the branch's commit: build on `push`, or check out
|
|
277
|
+
`github.event.pull_request.head.sha` and pass that commit as `ref` instead of `context.sha`.
|
|
278
|
+
|
|
203
279
|
### Check it
|
|
204
280
|
|
|
205
|
-
After the deploy finishes, run this in your repository
|
|
281
|
+
After the deploy finishes, run this in your repository:
|
|
206
282
|
|
|
207
283
|
```sh
|
|
208
|
-
|
|
284
|
+
npx @conloca/cli doctor --live
|
|
209
285
|
```
|
|
210
286
|
|
|
211
|
-
`--live`
|
|
212
|
-
the editor
|
|
213
|
-
|
|
214
|
-
rather than replacing the token (that stops the CI secret working at once); reloading the editor is enough.
|
|
287
|
+
`--live` reads the deployed `<host><base>_conloca/editor/conloca.json` and the page's headers, and the protocol range
|
|
288
|
+
the editor publishes at `https://app.conloca.com/host/protocols.json`, and judges them by the same rules the workspace
|
|
289
|
+
editor applies. It sends no credential, so it runs anywhere, pull requests from forks included.
|
|
215
290
|
|
|
216
|
-
Then
|
|
217
|
-
|
|
291
|
+
Then open your workspace editor at `<slug>.conloca.com`. Until the editor page is live, **Connect this site** lists the
|
|
292
|
+
steps the site still needs: each row says what is done, whom it waits on, or what failed and how to fix it.
|
|
218
293
|
|
|
219
294
|
### Troubleshooting
|
|
220
295
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
- **
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
296
|
+
Doctor names each check; the checklist in the workspace editor reports the same causes.
|
|
297
|
+
|
|
298
|
+
- **`sites.json` has no `domains` for the default locale, or not a bare host** (CC9). Run `connect`, or add your site's
|
|
299
|
+
host there (step 2). A host under `conloca.com`, an IP address or `localhost` is refused.
|
|
300
|
+
- **A committed header file sets `X-Frame-Options` or `frame-ancestors` for the whole site** (CC10). Run `connect`, or
|
|
301
|
+
add the rule from step 3.
|
|
302
|
+
- **The address cannot be reached, or answers 5xx or 429** (CC11). The site is down or limiting requests: check that it
|
|
303
|
+
is deployed and serving, then try again later.
|
|
304
|
+
- **`conloca.json` is not deployed** (CC11). The address answers 404 or an HTML page: deploy the commit that adds
|
|
305
|
+
`conlocaCloud()`, and check that `domains` names the address it is deployed to.
|
|
306
|
+
- **The address asks visitors to sign in** (CC11), for example Vercel Deployment Protection. Put the public production
|
|
307
|
+
address in `sites.json`, or let visitors through.
|
|
308
|
+
- **The page names no repository** (CC11). The build could not read the git remote: set `repoUri` in `conlocaCloud(...)`
|
|
309
|
+
(`connect` writes it from a checkout with a GitHub `origin`).
|
|
310
|
+
- **The address serves another repository's editor page, or another site** (CC11). Check `domains` and `siteId` in
|
|
311
|
+
`sites.json`.
|
|
312
|
+
- **`conloca.json` is not one the editor can read** (CC11). The host changed the built file; serve it unchanged.
|
|
313
|
+
- **The page is serving an older commit than your checkout** (CC11, a warning). Deploy to see your latest components.
|
|
314
|
+
- **The deployed page sends `X-Frame-Options`, or a `frame-ancestors` that leaves out `https://*.conloca.com`** (CC12).
|
|
315
|
+
Run `connect` again, or exempt `/_conloca/editor/` in your host settings (step 3).
|
|
316
|
+
- **The deployed page sends a `script-src` that does not allow `https://app.conloca.com`** (CC12). The page cannot load
|
|
317
|
+
the editor, and the workspace editor stops waiting for it. Detach the site's policy on `/_conloca/editor/` (step 3),
|
|
318
|
+
or add `https://app.conloca.com` to its `script-src` there.
|
|
319
|
+
- **The page's protocol is outside the range the editor speaks** (CC13). Rebuild with a newer `@conloca/cloud-astro` and
|
|
320
|
+
deploy; if the page is newer than the editor, the editor does not speak that version yet.
|
|
321
|
+
- **A workflow or the config still names `CONLOCA_BUILD_TOKEN`, `buildToken`, `publicBaseUrl`, `previewDomain` or
|
|
322
|
+
`requireRegistration`** (CC14). The editor page needs none of them: remove those lines. `connect` removes the workflow
|
|
323
|
+
lines that only pass the key.
|
|
238
324
|
|
|
239
325
|
## Options
|
|
240
326
|
|
|
241
|
-
| Name
|
|
242
|
-
|
|
|
243
|
-
| `endpoint`
|
|
244
|
-
| `puckConfigPath`
|
|
245
|
-
| `
|
|
246
|
-
| `
|
|
247
|
-
| `
|
|
248
|
-
| `
|
|
249
|
-
| `
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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`.
|
|
327
|
+
| Name | Required | Description |
|
|
328
|
+
| ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
329
|
+
| `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`. |
|
|
330
|
+
| `puckConfigPath` | no | Puck config entry to compile. Defaults to the value `conlocaCMS` was given. |
|
|
331
|
+
| `repoUri` | no | Advanced `owner/repo` override; normally detected from CI or the Git remote. |
|
|
332
|
+
| `siteId` | no | Advanced site-id override for CMS-less builds; sites.json is authoritative. |
|
|
333
|
+
| `siteStyles` | no | Site CSS compiled into the canvas stylesheet, as in `conlocaCMS`. |
|
|
334
|
+
| `previewBuild` | no | `PreviewBuildOptions` or `false`. Off unless given as an object. See [Draft previews](#draft-previews). Refused under `@astrojs/vercel` and `@astrojs/netlify`. |
|
|
335
|
+
| `saasIssuer` | no | Draft previews only. Pins the JWT `iss` every pass must name; unset, passes are checked against the endpoint's keys alone. |
|
|
336
|
+
|
|
337
|
+
The `conlocaCMS` options `schemasPath`, `mdxComponentFolders`, `templates`, the `routing` data bindings, `editorStyles`
|
|
338
|
+
and `editorCSS` reach the editor page automatically: the CMS publishes what it resolved, and the editor page renders
|
|
339
|
+
your pages with them as the local editor at `/__cms` does.
|
|
340
|
+
|
|
341
|
+
`buildToken`, `requireRegistration`, `publicBaseUrl`, `previewDomain`, `editorBundlePlugins` and `fragmentPreviewRoute`
|
|
342
|
+
were removed: a config that still names one fails at load. Run `npx @conloca/cli connect` to update it.
|
|
262
343
|
|
|
263
344
|
## Public render path
|
|
264
345
|
|
|
@@ -268,49 +349,139 @@ they did before.
|
|
|
268
349
|
|
|
269
350
|
## Draft previews
|
|
270
351
|
|
|
271
|
-
|
|
272
|
-
|
|
352
|
+
The editor's Preview button opens the draft on your site. How depends on the site:
|
|
353
|
+
|
|
354
|
+
| Your site | `previewBuild` | Where drafts render |
|
|
355
|
+
| ---------------------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
356
|
+
| Static, deployed to Cloudflare Workers | `{}` | Next to the site: a dispatcher runs only on `/_conloca/preview/*` and your on-demand routes. Every other page stays a static file, and no visitor to it starts a Worker |
|
|
357
|
+
| Static, on another host, or on Cloudflare without a domain of your own | `{ separate: true }` | A separate preview deploy; its address goes in `sites.json` `previewUrl` |
|
|
358
|
+
| Server-rendered (`@astrojs/cloudflare`, `@astrojs/node`) | `{}` | Your own deploy |
|
|
359
|
+
|
|
360
|
+
### Next to a static site on Cloudflare Workers
|
|
361
|
+
|
|
362
|
+
Install `@astrojs/cloudflare` and add `previewBuild: {}` to `conlocaCloud(...)`, then run `npx @conloca/cli connect`. It
|
|
363
|
+
asks once whether your account is on the Cloudflare Workers Paid plan (pass `--cf-plan free` or `--cf-plan paid` when no
|
|
364
|
+
one is at the terminal) and records the answer in `package.json` (`"conloca": { "cfPlan": "paid" }`). It writes
|
|
365
|
+
`wrangler.jsonc`; on the Paid plan it adds the `ratelimits` entry below (Wrangler 4.36 or newer), on the Free plan it
|
|
366
|
+
leaves it out:
|
|
367
|
+
|
|
368
|
+
```jsonc
|
|
369
|
+
{
|
|
370
|
+
"main": ".conloca/dispatcher/index.mjs",
|
|
371
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
372
|
+
"assets": {
|
|
373
|
+
"directory": "./dist",
|
|
374
|
+
"binding": "ASSETS",
|
|
375
|
+
"not_found_handling": "404-page",
|
|
376
|
+
"run_worker_first": ["/_conloca/preview", "/_conloca/preview/*"],
|
|
377
|
+
},
|
|
378
|
+
"ratelimits": [
|
|
379
|
+
{ "name": "conlocaPreviewLimit", "namespace_id": "<chosen by connect>", "simple": { "limit": 60, "period": 10 } },
|
|
380
|
+
],
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
`run_worker_first` also lists every route the preview build renders on demand (API routes, Actions, and `/_image` for
|
|
385
|
+
draft images). Every build checks the list, and on the Paid plan the rate limit, and fails with "run
|
|
386
|
+
`conloca connect --update --yes`" when one is missing, so an API route can never silently 404 in production. A
|
|
387
|
+
`wrangler.toml` can't carry these settings: convert it to `wrangler.jsonc` first. Keep `main` and `assets` out of
|
|
388
|
+
`env.<name>` blocks; both are inherited from the top level. To try previews locally, run
|
|
389
|
+
`wrangler dev --local-protocol https`: Safari refuses the preview's `Secure` cookies on plain-http `localhost`.
|
|
273
390
|
|
|
274
|
-
|
|
391
|
+
A static site can't hold an on-demand route itself: Astro refuses `export const prerender = false` without an adapter,
|
|
392
|
+
and an adapter would make the site preview from its own server deploy instead. Add such a route to the preview build
|
|
393
|
+
only, which runs with `CONLOCA_PREVIEW_BUILD=1`: the dispatcher then serves it next to the static site, and the build
|
|
394
|
+
reports it for `run_worker_first`. Keep its file outside `src/pages`:
|
|
275
395
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
396
|
+
```js
|
|
397
|
+
export default defineConfig({
|
|
398
|
+
integrations: [
|
|
399
|
+
// ...conlocaCMS(...), conlocaCloud({ previewBuild: {} }),
|
|
400
|
+
...(process.env.CONLOCA_PREVIEW_BUILD === '1'
|
|
401
|
+
? [
|
|
402
|
+
{
|
|
403
|
+
name: 'preview-only-routes',
|
|
404
|
+
hooks: {
|
|
405
|
+
'astro:config:setup': ({ injectRoute }) =>
|
|
406
|
+
injectRoute({ pattern: '/api/ping', entrypoint: './src/api/ping.ts', prerender: false }),
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
]
|
|
410
|
+
: []),
|
|
411
|
+
],
|
|
412
|
+
});
|
|
413
|
+
```
|
|
279
414
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
415
|
+
If the preview build fails and `run_worker_first` lists only the two preview entries, the site still builds and deploys,
|
|
416
|
+
and `/_conloca/preview/` answers "Preview couldn't load the draft". If it also lists your on-demand routes, or
|
|
417
|
+
`not_found_handling` is `"none"`, the build fails instead: the preview server is what serves those routes, and shipping
|
|
418
|
+
without it would break them.
|
|
419
|
+
|
|
420
|
+
On the Cloudflare Workers Paid plan the dispatcher limits each visitor to 60 requests under `/_conloca/preview/` per 10
|
|
421
|
+
seconds (the `ratelimits` binding, counted per Cloudflare location and approximately) and answers "Too many preview
|
|
422
|
+
requests — try again in a few seconds" over it. On the Free plan there is no limit: a blocked request would still count
|
|
423
|
+
against the day's requests, so a limit adds nothing there. A flood can then use up the day's requests and pause preview
|
|
424
|
+
until 00:00 UTC, but never the published pages, which don't run the dispatcher. A site with on-demand routes (API
|
|
425
|
+
routes, `/mcp`) still previews next to itself on the Free plan, since those routes need the dispatcher too, and
|
|
426
|
+
`conloca connect` and doctor (CC23) warn that previews and those routes share one daily request quota: a flood of
|
|
427
|
+
preview requests can stop those routes until 00:00 UTC. Cloudflare Workers Paid removes the daily limit. A rate-limiting
|
|
428
|
+
rule on `/_conloca/preview/*` in the Cloudflare dashboard (Security → WAF) stops a flood before it reaches the
|
|
429
|
+
dispatcher; it is optional, and doctor doesn't check it.
|
|
430
|
+
|
|
431
|
+
Not suited to this mode: sites that navigate on the client (view transitions, `navigate()`), call same-origin APIs that
|
|
432
|
+
should see drafts, load third-party tags that must not see draft content, open same-origin pages from scripts
|
|
433
|
+
(`window.open` would let the opener read a draft), or register a service worker that handles navigations (it would see
|
|
434
|
+
draft pages, and could cache them or answer published ones). Use a separate preview deploy.
|
|
435
|
+
|
|
436
|
+
### A separate preview deploy
|
|
437
|
+
|
|
438
|
+
Set `previewBuild: { separate: true }`. Your build then runs no preview build. Add a second deploy (for example a second
|
|
439
|
+
Cloudflare Workers Builds project) that builds with `CONLOCA_PREVIEW_BUILD=1 CLOUDFLARE_ENV=preview` before your build
|
|
440
|
+
command (`CLOUDFLARE_ENV` picks the Wrangler environment at build time, not at deploy) and deploys with a plain
|
|
441
|
+
`wrangler deploy`. Put its address in `sites.json`:
|
|
442
|
+
|
|
443
|
+
```json
|
|
444
|
+
{ "sites": { "default": { "previewUrl": { "en": "https://preview.example.com" } } } }
|
|
285
445
|
```
|
|
286
446
|
|
|
287
|
-
|
|
288
|
-
rejects always fails the build; there is no switch for that.
|
|
447
|
+
A workspace admin confirms the address in the editor once; from then on every preview link opens there.
|
|
289
448
|
|
|
290
449
|
## Doctor
|
|
291
450
|
|
|
292
451
|
This package is a `conloca doctor` extension (`conloca.doctor` in package.json): `conloca doctor` in a project that
|
|
293
452
|
depends on it runs this package's checks after the CMS ones, offline by default.
|
|
294
453
|
|
|
295
|
-
| Check | What it verifies
|
|
296
|
-
| ----- |
|
|
297
|
-
| CC1 | `conlocaCloud(...)` is wired next to `conlocaCMS(...)` (an absent `conlocaCMS` is an error)
|
|
298
|
-
|
|
|
299
|
-
|
|
|
300
|
-
|
|
|
301
|
-
|
|
|
302
|
-
|
|
|
303
|
-
|
|
|
304
|
-
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
454
|
+
| Check | What it verifies |
|
|
455
|
+
| ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
456
|
+
| CC1 | `conlocaCloud(...)` is wired next to `conlocaCMS(...)` (an absent `conlocaCMS` is an error); notes that the deployed `conloca.json` publishes the repository's name |
|
|
457
|
+
| CC8 | How the preview build serves drafts: next to a static site on Cloudflare Workers (D3), from the site's own server deploy (D2), or a separate deploy (D4) |
|
|
458
|
+
| 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) |
|
|
459
|
+
| 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 |
|
|
460
|
+
| 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 |
|
|
461
|
+
| CC12 | `--live`: the deployed `/_conloca/editor/` may be framed by `https://*.conloca.com` and its `script-src` allows the editor's origin |
|
|
462
|
+
| CC13 | `--live`: the page's protocol is in the range the editor publishes at `/host/protocols.json` |
|
|
463
|
+
| CC14 | No tracked workflow and not the astro config still names `CONLOCA_BUILD_TOKEN`, `buildToken`, `publicBaseUrl`, `previewDomain` or `requireRegistration` (warnings) |
|
|
464
|
+
| CC15 | D3/D4: a `wrangler.jsonc` deploys to Cloudflare Workers, not Pages; a `wrangler.toml` is asked to become `wrangler.jsonc` |
|
|
465
|
+
| CC16 | D3: the project's wrangler is 4.36 or newer (`run_worker_first` patterns and the `ratelimits` binding); a warning when it is not installed |
|
|
466
|
+
| CC17 | D3: `main` is the dispatcher, `nodejs_compat` is on, assets bind as `ASSETS`, `run_worker_first` covers the preview route (no `!` exclusion, at most 100 entries), no env block replaces `main` or `assets`, and 404 handling is not single-page-application. D4: `main` no longer names the D3 dispatcher, and without a `main` there is no assets `binding` and no `run_worker_first`, which Wrangler refuses on an assets-only deploy |
|
|
467
|
+
| CC18 | D3: `run_worker_first` lists every route the last build renders on demand |
|
|
468
|
+
| CC19 | D3: no `.wrangler/deploy/config.json` points a plain `wrangler deploy` at the preview server |
|
|
469
|
+
| CC20 | D3 (warning): the site has a 404 page (read from the build when there is one), unless `not_found_handling` is `"none"`; a middleware that negotiates responses gets the `"none"`-or-static choice |
|
|
470
|
+
| CC21 | D3: no tracked file loads a tag manager, which would run on draft pages (warning; recommends `separate: true`) |
|
|
471
|
+
| CC22 | D3, Paid plan (or none recorded): `wrangler.jsonc` (and every `env` block in it) has the `conlocaPreviewLimit` rate-limit binding at 60 requests per 10 s. Free plan: none expected, and one that is there is only noted. A rule in the Cloudflare dashboard is optional and not checked |
|
|
472
|
+
| CC23 | D3: `package.json` records the Cloudflare plan (`conloca.cfPlan`); on Free, a warning: with on-demand routes, that previews and those routes share one daily request quota |
|
|
473
|
+
| CC24 | `--live`, D4: `previewUrl`'s `conloca.json` answers as D4 and names the site's release |
|
|
474
|
+
|
|
475
|
+
`conloca doctor` reads the rate-limit binding and the recorded plan from your project's files; it never contacts
|
|
476
|
+
Cloudflare and needs no token. `conloca doctor --live` sends no credential: it contacts your site's host, its
|
|
477
|
+
`previewUrl` and the editor's public `/host/protocols.json`. When the config computes `endpoint` (for example from an
|
|
478
|
+
environment variable), set `CONLOCA_ENDPOINT` so doctor can read it.
|
|
308
479
|
|
|
309
480
|
The integration also scaffolds a one-page agent skill at `.claude/skills/conloca-cloud/SKILL.md` — in the nearest
|
|
310
481
|
`.claude/` directory between the Astro project and the git root — on any Astro command that loads the config (build,
|
|
311
482
|
dev, sync, check), once, never overwriting an existing file. Repos without a `.claude/` directory get nothing. Projects
|
|
312
|
-
outside a git repository get nothing either.
|
|
313
|
-
|
|
483
|
+
outside a git repository get nothing either. `conloca upgrade` refreshes it; an edited page is kept and the new one
|
|
484
|
+
written beside it as `SKILL.new.md`.
|
|
314
485
|
|
|
315
486
|
## Tests
|
|
316
487
|
|