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
{{ message }}
Repository navigation
Commit 80d1f77
Browse filesBrowse the repository at this point in the historyBrowse files
| The site, SSR, prerendered pages, `/api/*`| ✅ Works | One Worker answers every route; prerendered pages are served as static assets. |
16
16
|[WebSockets](/docs/dev/websocket)| ✅ Works | The realtime hub owns the sockets. See [Cloudflare WebSockets](/docs/dev/websocket/cloudflare). |
17
-
| Postgres | ✅ Works | Through `scopedDatabase`, one client per request. |
17
+
| Postgres | ✅ Works | Through `scopedDatabase`, one client per request, or [Hyperdrive](#connect-through-hyperdrive).|
18
18
|[S3 / R2](/docs/dev/storage/s3-r2), Supabase storage | ✅ Works | Uploads go straight to the bucket. |
19
19
|[Local file storage](/docs/dev/storage/local)| ❌ No disk | A Worker has no persistent file system. Use a bucket. |
20
20
| Image re-encoding (`storage.image`) | ❌ Unsupported | It needs `sharp`, a native module Workers cannot load. Leave `storage.image` out of the Worker build. |
@@ -26,7 +26,7 @@ A VitNode **Single App** builds into one Cloudflare Worker: the site, the Hono A
26
26
27
27
- A Single App, the one layout `create-vitnode-app` offers for Workers.
28
28
- Workers Paid. A VitNode Worker is above the 3 MiB limit of the Free plan; [Shrink the Worker](#shrink-the-worker) keeps it under the 10 MiB Paid limit.
29
-
- A PostgreSQL database that Cloudflare can reach over TCP.
29
+
- A PostgreSQL database that Cloudflare can reach over TCP. A Worker only trusts certificates from a public CA, so a provider such as Supabase needs [Hyperdrive](#connect-through-hyperdrive).
@@ -197,6 +197,50 @@ An app made with `--deploy cloudflare` has these commands as its `preview`, `che
197
197
</Step>
198
198
</Steps>
199
199
200
+
## Connect through Hyperdrive
201
+
202
+
A Worker opens its own TLS connection to `POSTGRES_URL` and only accepts a certificate signed by a public CA. Supabase signs its database certificates with its own CA, so every API request fails with `TLS_HANDSHAKE_FAILED`. [Hyperdrive](https://developers.cloudflare.com/hyperdrive/) is Cloudflare's database proxy: it opens that connection for the Worker and pools it across requests.
203
+
204
+
Create a Hyperdrive config from your app's folder. For Supabase, use the **Direct connection** string, not a pooler one, because Hyperdrive does the pooling:
`scopedDatabase` passes the Worker's bindings to its callback as `env`, and `hyperdriveConnectionString(env)` returns the binding's connection string, or `undefined` on Node and in a Worker without the binding. Fall back to `POSTGRES_URL`, so `vite dev` and `db:migrate` keep using it:
Pass the binding's name as the second argument, `hyperdriveConnectionString(env, 'DATABASE')`, if you named it something else.
243
+
200
244
## Shrink the Worker
201
245
202
246
By default Wrangler uploads every module the build wrote, including chunks nothing imports, without minifying them. A large app, with many plugins or compiled docs, can pass the 10 MiB Paid limit that way. Let Wrangler bundle from the entry and minify:
| The Worker ignores `.dev.vars`, and the bindings table lists none of its variables | Wrangler ran with `--config .output/server/wrangler.json`. Run `wrangler dev` from the app's folder without it. |
224
-
| A Worker-rendered page fails with `n is not defined` in the browser | The Worker is minified with `keep_names` on. Set `"keep_names": false`. |
225
-
|`CONNECTION_CLOSED` or `Cannot perform I/O on behalf of a different request` from the database | The client was created once at module load. Use `scopedDatabase`. |
226
-
| Image uploads fail with "The image optimization library (sharp) failed to load" | Remove `storage.image` from the Worker's API config. |
227
-
| Deploy fails with `total sourcemap size is too large` (code `10021`) | Set `"upload_source_maps": false` in `wrangler.jsonc`. |
228
-
| Deploy fails because the script is too large |[Shrink the Worker](#shrink-the-worker), and check that you are on Workers Paid. |
| The Worker ignores `.dev.vars`, and the bindings table lists none of its variables | Wrangler ran with `--config .output/server/wrangler.json`. Run `wrangler dev` from the app's folder without it. |
268
+
| A Worker-rendered page fails with `n is not defined` in the browser | The Worker is minified with `keep_names` on. Set `"keep_names": false`. |
269
+
|`CONNECTION_CLOSED` or `Cannot perform I/O on behalf of a different request` from the database | The client was created once at module load. Use `scopedDatabase`. |
270
+
|`TLS_HANDSHAKE_FAILED` from the database, and `/api/health/ready` answers `503`| The database's certificate is not signed by a public CA, as with Supabase. [Connect through Hyperdrive](#connect-through-hyperdrive). |
271
+
| Image uploads fail with "The image optimization library (sharp) failed to load" | Remove `storage.image` from the Worker's API config. |
272
+
| Deploy fails with `total sourcemap size is too large` (code `10021`) | Set `"upload_source_maps": false` in `wrangler.jsonc`. |
273
+
| Deploy fails because the script is too large |[Shrink the Worker](#shrink-the-worker), and check that you are on Workers Paid. |
0 commit comments