astro site with kv binding deploys but doesn't work
Hey folks 👋 I've got a working astro site with no special setup or the cloudflare integration, and I'm on to my second but this one has a KV binding that I'm attempting to access on the homepage. Things deploy fine/no build errors, but the site throws a 500 and I'm not sure where to find the logs
// astro.config.mjs
import { defineConfig } from "astro/config"
import svelte from "@astrojs/svelte"
import tailwind from "@astrojs/tailwind"
import cloudflare from "@astrojs/cloudflare"
// https://astro.build/config
export default defineConfig({
integrations: [svelte(), tailwind()],
output: "server",
adapter: cloudflare({
runtime: {
mode: "local",
type: "pages",
bindings: {
A_LINKS_KV: {
type: "kv",
},
},
},
}),
})
// astro.config.mjs
import { defineConfig } from "astro/config"
import svelte from "@astrojs/svelte"
import tailwind from "@astrojs/tailwind"
import cloudflare from "@astrojs/cloudflare"
// https://astro.build/config
export default defineConfig({
integrations: [svelte(), tailwind()],
output: "server",
adapter: cloudflare({
runtime: {
mode: "local",
type: "pages",
bindings: {
A_LINKS_KV: {
type: "kv",
},
},
},
}),
})
1 Reply
last few lines from my build logs
is there a way to prerender the homepage (force ssg) with the kv binding at build time?
my kv store my update frequently, is it safe to assume the worker will be cached somewhat aggressively?
fwiw
09:58:26.421 17:58:26 [WARN] [@astrojs/cloudflare] The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice
09:58:26.491 17:58:26 [vite] Forced re-optimization of dependencies
09:58:26.523 17:58:26 [build] output: "server"
09:58:26.523 17:58:26 [build] directory: /opt/buildhome/repo/apps/www/dist/
09:58:26.524 17:58:26 [build] adapter: @astrojs/cloudflare
09:58:26.524 17:58:26 [build] Collecting build info...
09:58:26.524 17:58:26 [build] ✓ Completed in 149ms.
09:58:26.525 17:58:26 [build] Building server entrypoints...
09:58:27.802 @astrojs-ssr-virtual-entry (20:23) "start" is not exported by "../../node_modules/.pnpm/@[email protected][email protected]/node_modules/@astrojs/cloudflare/dist/entrypoints/server.advanced.js", imported by "@astrojs-ssr-virtual-entry".
09:58:28.062 17:58:28 [build] ✓ Completed in 1.54s.
09:58:28.063
09:58:28.063 building client (vite)
09:58:28.074 17:58:28 [vite] transforming...
09:58:28.344 17:58:28 [vite] ✓ 41 modules transformed.
09:58:28.365 17:58:28 [vite] rendering chunks...
09:58:28.375 17:58:28 [vite] computing gzip size...
09:58:28.377 17:58:28 [vite] dist/_astro/constants.v9qu712v.js 0.26 kB │ gzip: 0.21 kB
09:58:28.378 17:58:28 [vite] dist/_astro/client.bWR2MAd2.js 0.61 kB │ gzip: 0.42 kB
09:58:28.378 17:58:28 [vite] dist/_astro/hoisted.dbx9PSHC.js 2.11 kB │ gzip: 1.07 kB
09:58:28.378 17:58:28 [vite] dist/_astro/BrowserWindow.sqDu4Ddl.js 5.25 kB │ gzip: 2.39 kB
09:58:28.378 17:58:28 [vite] dist/_astro/Nav.LqYcgZl4.js 5.36 kB │ gzip: 2.16 kB
09:58:28.379 17:58:28 [vite] dist/_astro/index.lZQkxUQ0.js 7.09 kB │ gzip: 2.90 kB
09:58:28.379 17:58:28 [vite] ✓ built in 308ms
09:58:28.391 17:58:28
09:58:28.391 finalizing server assets
09:58:28.391
09:58:28.391 17:58:28 [build] Rearranging server assets...
09:58:28.440 17:58:28 [build] Server built in 2.07s
09:58:28.440 17:58:28 [build] Complete!
09:58:28.484 Finished
09:58:28.485 Found _worker.js in output directory. Uploading.
09:58:29.677 ✨ Compiled Worker successfully
09:58:29.745 Found _routes.json in output directory. Uploading.
09:58:29.758 Validating asset output directory
09:58:30.476 Deploying your site to Cloudflare's global network...
09:58:33.416 Uploading... (20/20)
09:58:33.417 ✨ Success! Uploaded 0 files (20 already uploaded) (0.29 sec)
09:58:33.417
09:58:33.868 ✨ Upload complete!
09:58:36.084 Success: Assets published!
09:58:38.857 Success: Your site was deployed!
09:58:26.421 17:58:26 [WARN] [@astrojs/cloudflare] The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice
09:58:26.491 17:58:26 [vite] Forced re-optimization of dependencies
09:58:26.523 17:58:26 [build] output: "server"
09:58:26.523 17:58:26 [build] directory: /opt/buildhome/repo/apps/www/dist/
09:58:26.524 17:58:26 [build] adapter: @astrojs/cloudflare
09:58:26.524 17:58:26 [build] Collecting build info...
09:58:26.524 17:58:26 [build] ✓ Completed in 149ms.
09:58:26.525 17:58:26 [build] Building server entrypoints...
09:58:27.802 @astrojs-ssr-virtual-entry (20:23) "start" is not exported by "../../node_modules/.pnpm/@[email protected][email protected]/node_modules/@astrojs/cloudflare/dist/entrypoints/server.advanced.js", imported by "@astrojs-ssr-virtual-entry".
09:58:28.062 17:58:28 [build] ✓ Completed in 1.54s.
09:58:28.063
09:58:28.063 building client (vite)
09:58:28.074 17:58:28 [vite] transforming...
09:58:28.344 17:58:28 [vite] ✓ 41 modules transformed.
09:58:28.365 17:58:28 [vite] rendering chunks...
09:58:28.375 17:58:28 [vite] computing gzip size...
09:58:28.377 17:58:28 [vite] dist/_astro/constants.v9qu712v.js 0.26 kB │ gzip: 0.21 kB
09:58:28.378 17:58:28 [vite] dist/_astro/client.bWR2MAd2.js 0.61 kB │ gzip: 0.42 kB
09:58:28.378 17:58:28 [vite] dist/_astro/hoisted.dbx9PSHC.js 2.11 kB │ gzip: 1.07 kB
09:58:28.378 17:58:28 [vite] dist/_astro/BrowserWindow.sqDu4Ddl.js 5.25 kB │ gzip: 2.39 kB
09:58:28.378 17:58:28 [vite] dist/_astro/Nav.LqYcgZl4.js 5.36 kB │ gzip: 2.16 kB
09:58:28.379 17:58:28 [vite] dist/_astro/index.lZQkxUQ0.js 7.09 kB │ gzip: 2.90 kB
09:58:28.379 17:58:28 [vite] ✓ built in 308ms
09:58:28.391 17:58:28
09:58:28.391 finalizing server assets
09:58:28.391
09:58:28.391 17:58:28 [build] Rearranging server assets...
09:58:28.440 17:58:28 [build] Server built in 2.07s
09:58:28.440 17:58:28 [build] Complete!
09:58:28.484 Finished
09:58:28.485 Found _worker.js in output directory. Uploading.
09:58:29.677 ✨ Compiled Worker successfully
09:58:29.745 Found _routes.json in output directory. Uploading.
09:58:29.758 Validating asset output directory
09:58:30.476 Deploying your site to Cloudflare's global network...
09:58:33.416 Uploading... (20/20)
09:58:33.417 ✨ Success! Uploaded 0 files (20 already uploaded) (0.29 sec)
09:58:33.417
09:58:33.868 ✨ Upload complete!
09:58:36.084 Success: Assets published!
09:58:38.857 Success: Your site was deployed!
wrangler pages dev ./dist
seems fine
I've confirmed this is specifically erroring out on the kv fetch. if I remove that line from my homepage and deploy with another endpoint it works fine, but the endpoint with kv does not