I'm having a ridiculous amount of trouble getting the simplest of pages functions to work on a nextj

I'm having a ridiculous amount of trouble getting the simplest of pages functions to work on a nextjs project deployed on cloudflare(has been great). To see if I could figure it out I made a brand new project (following the docs to the letter) using 'npm create cloudflare@latest my-next-app -- --framework=next' - as I am using the Pages router I chose that option during the build. Works fine, deploys fine, the basic /api/hello route returns the expected hello world text. I have setupDevPlatform() in place. Then following the docs I created a /functions directory and added the basic code supplied
export function onRequest(context) {
  return new Response("Hello, world!")
}
which just seems to be ignored. It's seemingly not recognised when it is added, it's not available in the way that /api/hello is on api/helloworld (404), running npm run preview makes no difference. I've crawled all over the docs - can someone please point me in the right direction? Have added a few files with my setup.
Was this page helpful?