How to point Worker & NextJs app to the Same Local D1 Clone SQL File

I am using monorepo in my NextJs project

i have 3 folders inside my apps folder
1. apps/web : my Nextjs Project hosted on cloudflare Pages
2. apps/linkp-worker: my cloudflare worker to assist my main application
3. apps/shared/v3/d1: this is where my local D1 sql clone sits

now i want my web and worker to use this D1 clone in the shared folder, but it seems thats not possible.

so far i have tried the
--persist-to
command

wrangler dev --local --persist-to=../shared ran this inside my worker apps/linkp-worker
its starts the server but throws this error: TypeError: Cannot read properties of undefined (reading 'prepare')


Then, when i start my Nextjs server from bun run dev inside the apps/web it created a .wranger folder inside the web folder and uses its own sql clone, instead of pointing to the shared folder

and there is not
--persist-to
command for
next dev
command.

this is super furstrating
Was this page helpful?