API routes in nextjs is not running and giving "no such module" error
I have a nextjs project which is using next on pages to build it for the cloudflare pages platform. I followed the documentation here: https://developers.cloudflare.com/pages/framework-guides/nextjs/ssr/get-started/
I am also using D1 as my database. Running the development server, I can send requests to my
/api/waitlist
route, where waitlist
is the route defined, and I am able to save data to my local D1 correctly.
The problem comes when I run a build preview using this package.json
script: "preview": "npm run cfbuild && wrangler pages dev --port 3005"
.
It builds the project perfectly fine and I am using the experimental-edge
runtime.
When the wrangler dev server starts and I make a request to my /api/waitlist
route, it is throwing the following error:
I don't know why I am getting this error and how do i fix it? Please help.
I am using this version of "@cloudflare/next-on-pages": "^1.13.7",
in my package.json.0 Replies