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

For Workes & Pages, what is the name of the domain?

localhost:8787/

What is the error message?

Cannot read properties of undefined (reading ‘prepare’)

What is the issue or error you’re encountering

It seems my worker is unable to find the bindings for my D1

What steps have you taken to resolve the issue?

  • Tried multiple --persist-to locations.
  • confirmed that the d1 SQL inside the shared folders has the tables and values, confirmed from drizzle studio

What are the steps to reproduce the issue?

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

Screenshot of the error