Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cloudflare-prerender-remote-bindings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---

Fixes `remoteBindings: false` being ignored during `astro build`. The Cloudflare prerenderer's internal Vite preview server now receives the user's adapter options, so remote-flagged bindings (e.g. a D1 database with `remote: true` in `wrangler.toml`) are emulated locally during build, matching the existing `astro dev` behavior.
1 change: 1 addition & 0 deletions packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ export default function createIntegration({
if (prerenderEnvironment === 'workerd') {
setPrerenderer(
createCloudflarePrerenderer({
cloudflareOptions,
root: _config.root,
serverDir: _config.build.server,
clientDir: _config.build.client,
Expand Down
10 changes: 9 additions & 1 deletion packages/integrations/cloudflare/src/prerenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from './utils/prerender-constants.js';

interface CloudflarePrerendererOptions {
cloudflareOptions: Partial<PluginConfig>;
root: AstroConfig['root'];
serverDir: AstroConfig['build']['server'];
clientDir: AstroConfig['build']['client'];
Expand All @@ -35,6 +36,7 @@ interface CloudflarePrerendererOptions {
* This allows prerendering to happen in the same runtime that will serve the pages.
*/
export function createCloudflarePrerenderer({
cloudflareOptions,
root,
serverDir,
clientDir,
Expand Down Expand Up @@ -82,7 +84,13 @@ export function createCloudflarePrerenderer({
port: 0, // Let the OS pick a free port
open: false,
},
plugins: [cfVitePlugin({ ...cfPluginConfig, viteEnvironment: { name: 'prerender' } })],
plugins: [
cfVitePlugin({
...cloudflareOptions,
...cfPluginConfig,
viteEnvironment: { name: 'prerender' },
}),
],
Comment on lines +87 to +93
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im a bit anxious still about cfPluginConfig, will this ever include its own remoteBindings boolean that could override cloudflareOptions ?

});

const address = previewServer.httpServer.address();
Expand Down
Loading