Donnager
Donnager
CDCloudflare Developers
Created by Donnager on 8/21/2023 in #pages-help
n00b Q: wrangler / pages d1 env Qs
hello all, attempting to get next-on-pages dev env working with d1, 1. i realized it's defaulting to local, but i am unable to pass the --remote flag, as it throws an error saying its unrecognized:
pgrep workerd | xargs kill && npx wrangler pages dev .vercel/output/static --kv=MY_KV --d1=test --remote --compatibility-flag=nodejs_compat


✘ [ERROR] Unknown argument: remote
pgrep workerd | xargs kill && npx wrangler pages dev .vercel/output/static --kv=MY_KV --d1=test --remote --compatibility-flag=nodejs_compat


✘ [ERROR] Unknown argument: remote
i think its because this is wrangler pages dev and not wrangler dev, but in pages it states to use --local, i tried that as well and it just defaults to local anyway:
> pgrep workerd | xargs kill && npx wrangler pages dev .vercel/output/static --local=false --kv=MY_KV --d1=test --compatibility-flag=nodejs_compat

wrangler dev now uses local mode by default, powered by 🔥 Miniflare and 👷 workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
Your worker has access to the following bindings:
- KV Namespaces:
- MY_KV: MY_KV
- D1 Databases:
- test: local-test (test)
> pgrep workerd | xargs kill && npx wrangler pages dev .vercel/output/static --local=false --kv=MY_KV --d1=test --compatibility-flag=nodejs_compat

wrangler dev now uses local mode by default, powered by 🔥 Miniflare and 👷 workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
Your worker has access to the following bindings:
- KV Namespaces:
- MY_KV: MY_KV
- D1 Databases:
- test: local-test (test)
2. i also realized when i use wrangler commands its defaulting to cloud/non local so i was getting confused between the two envs, how do i set wrangler to target pages-dev env? there doesn't appear to be a --local flag for the d1 commands, also doesn't appear to be a port flag to target the local 8788 env created by pages dev
wrangler --version
⛅️ wrangler 3.5.1
wrangler --version
⛅️ wrangler 3.5.1
not sure if this should go here, in wrangler, or in d1, if anyone has any suggestions super open or if there is a part of the docs i missed please do not hesitate to let me know!
10 replies
CDCloudflare Developers
Created by Donnager on 8/21/2023 in #pages-help
n00b Q: next-on-pages + D1 binding
i have seen some conversations and examples on discord, but still running into some mistakes, 1. if i try to access a d1 binding using the suggested dev approach (watch build + wrangler pages dev), i am able to access the d1 instance (the instance is not undefined and the dev command shows a binding to the d1 db created from the gui), but not view the table (e.g., wrangler crashes saying table does not exist, but i can confirm it exists by using the CLI), i think i am misunderstanding how wrangler pages links to the d1 db, i.e., does the dev command create a local one or is there a flag to pass? 2. when using the npm run dev + cf-proxy workflow, i am able to access kv, but not d1, e.g., it returns undefined when wrapping it: binding(process.env.db), if there is any documentation or an example repo please do not hesitate to simply link me there! the KV repo example was super informative, not sure if there is anything else like that
10 replies