Cannot Interact with D1 Locally on Cloudflare Pages
Hi I'm currently facing an issue, i'm getting an error D1_ERROR: no such table:
But if I publish the project and access it, it works.
I don't know if I'm missing something.
I have a wrangler.toml file in my pages, that connect the D1.
Would appreciate if anyone could share how to fix it!
6 Replies
Trying to debug it, on the local dev returning on tables it shows this
{
"success": true,
"meta": {
"served_by": "miniflare.db",
"duration": 0,
"changes": 0,
"last_row_id": 0,
"changed_db": false,
"size_after": 8192,
"rows_read": 1,
"rows_written": 0
},
"results": [
{
"name": "_cf_KV"
}
]
}
but when I run this on my live it returns this. The tables are working on my live but not showing on local dev.
{
"success": true,
"meta": {
"served_by": "v3-prod",
"duration": 0.298,
"changes": 0,
"last_row_id": 0,
"changed_db": false,
"size_after": 212992,
"rows_read": 32,
"rows_written": 0
},
"results": [
{
"name": "_cf_KV"
},
{
"name": "Users"
},
{
"name": "Domains"
}
]
}
https://github.com/leaysgur/cfw-bindings-wrangler-bridge
a proxy to run d1, r2 ... locally
GitHub
GitHub - leaysgur/cfw-bindings-wrangler-bridge: This bridge makes i...
This bridge makes it possible to interact with remote Cloudflare Workers bindings(like KV, D1, etc...) from anywhere you want. - leaysgur/cfw-bindings-wrangler-bridge
couldn't get it to work, getting error
Wrong usage of bridge worker. Required headers are not presented.
Hey 👋
Could you share what framework you're using on CF Pages? I've had this work flawlessly for me in Remix for a while.
I'm not usingg any framework, just html, css, and js
Ahh, ok not really sure what the process is to setup interactions without a framework. I know frameworks like remix use
getPlatformProxy
internally to communicate with wrangler and Miniflare - https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxyCloudflare Docs
API · Cloudflare Workers docs
A set of programmatic APIs that can be integrated with local Cloudflare Workers-related workflows.