You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/cloudflare/cli.mdx
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,43 @@ The `populateCache` command supports R2 batching to speed up the upload of large
36
36
37
37
</Callout>
38
38
39
+
#### Populating remote bindings when Workers are protected by Cloudflare Access
40
+
41
+
`populateCache remote` (also called implicitly by `deploy` and `upload`) temporarily deploys a helper Worker named `open-next-cache-populate` at `open-next-cache-populate.<account>.workers.dev` and uses it to write to your remote R2 bucket.
42
+
43
+
If your account's `workers.dev` subdomain — or a parent route on a custom domain — is protected by [Cloudflare Access](https://developers.cloudflare.com/cloudflare-one/applications/), the helper Worker is protected by the same policy and the upload fails with either:
44
+
45
+
```text
46
+
Failed to send request to R2 worker: The operation was aborted due to timeout.
47
+
```
48
+
49
+
or a `403 Forbidden` returned by the Access edge.
50
+
51
+
To let the adapter authenticate:
52
+
53
+
1. Open the **existing** Cloudflare Access application that already covers `open-next-cache-populate.<account>.workers.dev` — typically the wildcard application for `*.<account>.workers.dev` — and attach the policy described below to that application.
54
+
55
+
<Callouttype="warning">
56
+
Creating a separate Access application scoped specifically to the `open-next-cache-populate` hostname has
57
+
been observed to block the upload, even when kept alongside the existing wildcard application (see
58
+
[#1171](https://github.com/opennextjs/opennextjs-cloudflare/issues/1171)). Prefer attaching the policy to
59
+
the existing application that already protects the hostname.
60
+
</Callout>
61
+
62
+
2. Add a **Service Auth** policy to that application:
63
+
64
+
- Set the policy **Action** to "Service Auth".
65
+
- Add an **Include** rule for "Any Access Service Token", or for a specific service token.
66
+
67
+
3. Create the service token under Zero Trust → Access → Service Auth → Service Tokens, then expose its credentials to the environment that runs `opennextjs-cloudflare`:
68
+
69
+
```sh
70
+
export CLOUDFLARE_ACCESS_CLIENT_ID=<id>
71
+
export CLOUDFLARE_ACCESS_CLIENT_SECRET=<secret>
72
+
```
73
+
74
+
Then run `opennextjs-cloudflare populateCache remote` (or `deploy` / `upload`). In CI, set the two values as secrets and expose them to the deploy step.
75
+
39
76
### `preview` command
40
77
41
78
It starts by populating the local cache and then launches a local development server (via `wrangler dev`) so that you can preview the application locally.
Copy file name to clipboardExpand all lines: pages/cloudflare/troubleshooting.mdx
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,3 +135,9 @@ To fix this issue, update your `compatibility_date` in `wrangler.toml` or `wrang
135
135
```
136
136
137
137
Refer to the [Cloudflare Workers compatibility flags documentation](https://developers.cloudflare.com/workers/configuration/compatibility-flags/#enable-finalizationregistry-and-weakref) for more details.
138
+
139
+
### `Failed to send request to R2 worker` or `Could not determine Cloudflare auth credentials after login`
140
+
141
+
These errors come from `populateCache remote` (called implicitly by `deploy` and `upload`) when the temporary `open-next-cache-populate.<account>.workers.dev` helper Worker is fronted by a Cloudflare Access application.
142
+
143
+
See [Populating remote bindings when Workers are protected by Cloudflare Access](/cloudflare/cli#populating-remote-bindings-when-workers-are-protected-by-cloudflare-access) for setup steps.
0 commit comments