@cloudflare/next-on-pages is for deploying full-stack Next.js apps to Cloudflare Pages. Therefore, you should be using native Next.js features. The functions directory will not work with next-on-pages because we have our own worker to handle your requests. If you want to use the functions directory, you won't be able to use next-on-pagesvercel.json, but it doesn't seem to be working :/yarn install, I didn't do anything else

getRequestContext is part of the top-level scope of a file, as you can see here: https://github.com/dario-piotrowicz/next-on-Pages-top-level-getRequestContext-bug-reprogetRequestContext calls to happen, but since you're in nodejs the context is not presentedge runtime config getRequestContext just return undefined during prerendering, but if there is other code that on the top level uses such bindings it could be problematic, so I'll have to experiment and think about it a bit...getRequestContext from the top level 
nodejs is not supported) technically it could work in the nodejs runtime during development but there are two major issues with that:getRequestContext and the process.env bindings work in dev mode is via this hack I came up with in which we can basically monkey patch the edge runtime context so that it the require data is made available there, I don't think there is such hack for the nodejs runtime (as next dev also actually runs your nodejs code in a separate child process, making hacks very difficult to do without actually modifying the next dev server itself)setupDevPlatform? It seems im having difficulty configuring a D1 database to work both locally and in production.
setupDevPlatform call can stay as is, what you need to change is getRequestContext and make sure that it is not being called as part of the route initialization (e.g. don't put getRequestContext() to the top level of a route file, but have it part of a function that gets called when the route is actually run)getRequestContext can't be called within an actions.ts due to edge runtime requirement. Gana have to find another way to populate data to a client component.
getRequestContextgetRequestContextgetRequestContextgetRequestContextgetRequestContextgetRequestContextgetRequestContextedgeruntimenodejsnodejsnodejsnodejsnext devsetupDevPlatformsetupDevPlatform