-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Describe the bug
What problem are we solving and why? (This section copied from @irvinebroque)
- Next.js has SSG (static-site generation) where it takes a route and at build time renders the page to generate the static content, that is then uploaded as part of the app.
- Sometimes people (ex: @wesbos https://x.com/wesbos/status/1871250855607042293) build routes that depend on data from D1/KV/R2 — ex: put posts in D1 db, render posts from DB
- This works fine with dynamic routes, but doesn't work with static routes (SSG) (Example SSG route)
- Why?
- Because when you run the Next.js build step (via @opennextjs/cloudflare) — this is using getPlatformProxy() behind the scenes to provide access to bindings
- getPlatformProxy() only supports local dev bindings provided by Miniflare — it does not support --remote
- This means that if you have a D1 DB you have created, where your data lives and is stored, you can't access it at build time
For Cloudflare Internal Employees:
- https://wiki.cfdata.org/pages/viewpage.action?pageId=1063901444
- https://jira.cfdata.org/browse/BANDA-589
Steps to reproduce
Steps to Reproduce:
I have a sample repo https://github.com/thomas-desmond/empty-hall-5379 that can be forked but you will need to create your database, see step 2.
-
Generate a new Next.js application
npm create cloudflare@latest my-next-app – --framework=next --experimental(See https://developers.cloudflare.com/workers/frameworks/framework-guides/nextjs/) -
Follow the walkthrough to add a D1 database and make a call to that database in your Next.js application. https://developers.cloudflare.com/d1/get-started/ Here is the call I made in my Next.js application page.tsx https://github.com/thomas-desmond/empty-hall-5379/blob/main/src/app/page.tsx
-
Push the repository to GitHub
-
Create a new Workers application and connect it to the GitHub repository.
-
Push changes or trigger a rebuild, and it should fail as previously indicated, displaying an error that states it could not find the database table, despite its existence in your account.
Expected behavior
Workers Assets should be able to access bindings at build time
@opennextjs/cloudflare version
0.3.2
Wrangler version
3.99.0
next info output
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 32206
Available CPU cores: 22
Binaries:
Node: 20.16.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.2.5 // An outdated version detected (latest is 15.1.4), upgrade is highly recommended!
eslint-config-next: 14.2.5
react: 18.3.1
react-dom: 18.3.1
typescript: 5.7.2
Next.js Config:
output: N/A
⚠ An outdated version detected (latest is 15.1.4), upgrade is highly recommended!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issueAdditional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status