JS.next on pages problems.
Hi Cloudflare Discord,
I have been working on a next.js webapp and trying to get it deployed to Cloudflare, but I am having some issues getting my D1 database hooked up and my functions recognized. This is my first time deploying to Cloudflare pages and my first Next.JS app, so I am considering just starting over with a demo project to get things working, but I thought I would ask for some help here first in case I am close to getting it functional.
I have followed the Next.JS guide on the Cloudflare docs, but no luck. I am probably just missing something super obvious.
Anyway, I can get it all built and uploaded, the front end loads up great, my database is all set up in Cloudflare dashboard, and I can see the bindings load in from my wrangler.toml, but no matter what I have tried I am getting 500 errors from all my API endpoints! When I look into it, I can see that my build is creating a middleware file that seems to be pointing our system to the wrong place. I have tried a bunch of things, setting up custom functions, different configs, checking for incompatibilities, and I seem like I am just running in circles.
The link is: https://rhystic-browser.pages.dev/
I attached a couple images of my CF dashboard settings, but let me know if there if anything else I should share and I will report back with more info!
❤️
rhystic.app
Browse and search for Magic: The Gathering Arena cards



2 Replies
You can't use the functions directory if you're using next-on-pages as it generates its own worker to use - instead you need to use Next.js API routes.
Yeah, I had been trying to get that working initially, but was getting a bunch of conflicting information. I will try to restore that commit and see if I can figure it out from there, and if not I will pop back with a more specific question