lbguilherme
lbguilherme
CDCloudflare Developers
Created by lbguilherme on 5/20/2024 in #workers-help
Does Smart Placement support Hyperdrive? I'm using Next.js with Postgres
there are a few more tricks to get it working on dev mode as well. Either way, I can't go to production with this without Smart Placement working
7 replies
CDCloudflare Developers
Created by lbguilherme on 5/20/2024 in #workers-help
Does Smart Placement support Hyperdrive? I'm using Next.js with Postgres
1. Add this to nextconfig:
webpack: (config, { webpack }) => {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(/^node:stream$/, "readable-stream")
);

config.externals.push({ "cloudflare:sockets": "global __edge_sockets" });

return config;
},
webpack: (config, { webpack }) => {
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(/^node:stream$/, "readable-stream")
);

config.externals.push({ "cloudflare:sockets": "global __edge_sockets" });

return config;
},
2. build with next-on-pages 3. run sed -i '1s/^/import * as cloudflare_sockets from \"cloudflare:sockets\"\\nglobalThis.__edge_sockets = cloudflare_sockets;\\n/' .vercel/output/static/_worker.js/index.js 4. deploy with wrangler
7 replies