What's the recommended way to build a

What's the recommended way to build a site with Pages using Hyperdrive? Every time I build (whether it's locally or on CF), I get this error:
Error: When developing locally, you should use a local Postgres connection string to emulate Hyperdrive functionality. Please setup Postgres locally and set the value of the 'WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE' variable or "HYPERDRIVE"'s "localConnectionString" to the Postgres connection string.
Error: When developing locally, you should use a local Postgres connection string to emulate Hyperdrive functionality. Please setup Postgres locally and set the value of the 'WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE' variable or "HYPERDRIVE"'s "localConnectionString" to the Postgres connection string.
For my local env, I did add that variable and it worked. However, I don't know what to do when using automated deploys from Github. I don't want to add this to the Cloudflare env (if I add it, it does work to fix the error) because I don't want it to overwrite Hyperdrive actually working properly. How do I build a pages site with Hyperdrive on Cloudflare? Build log for reference: db4f9c3e-eba7-4acd-ae2c-3f8835bf48ae
6 Replies
benank
benankOP16mo ago
Update: I got this to work. I needed a WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE env var everywhere I build, and it needs to be a valid db connection string (not sure if it actually needs to connect, but I just passed it my dev db connection string). After building, it will only use the actual hyperdrive binding and won't use the local connection string. Not a great experience and makes me a bit worried that I might connect to the wrong db, but it works.
Matt Silverlock
Matt Silverlock16mo ago
cc @thomasgauvin
Producer & Director Izumi Sakai
Cloudflare ゼロトラストヘルプ 安全を確認してください ファイアーウォールポリシー設定Workspage R2 SSL/TSL 証明書 1.1.1.1 WARP クライアント Cloudflare Zero Trust Agent One Downloadしてください
felixnorden
felixnorden3mo ago
Ty for this! Facing the same issue. If there's a way to easily leverage the Zero Trust tunnel and overall shared connection, that would make the DX almost seamless!
thomasgauvin
thomasgauvin3mo ago
What are you referring to here @felixnorden ? Are you referring to support for tunnels from Hyperdrive? https://developers.cloudflare.com/hyperdrive/configuration/connect-to-private-database/
Cloudflare Docs
Connect to a private database using Tunnel
Hyperdrive can securely connect to your private databases using Cloudflare Tunnel and Cloudflare Access.
felixnorden
felixnorden3mo ago
No, it was more the overall setup with the workers build pipeline and the use of the variable “WRANGLER_HYPERDRIVE…” that wasn’t intuitive/clear at first as it’s meant to be used in the local dev environment. If it would be possible to have this be accessible during the actual build step as well when it runs in the cloud, it would take it from “great” to “amazing” 🫡

Did you find this page helpful?