Hello,
I’m using pages to setup my website.
And I’m building my site with nextjs which supports /api
route by default, and after it initializing the project, it comes with pages/api/hello.js
and it can be accessed on my local machine when testing/developing, but can’t be accessed after deployed to Cloudflare pages.
Then I tried adding the functions folder to my project( following the documentation), and /api/
route works.
So my assumption is that pages will block route to /api/*
even there’s not functions
folder in my project and then the built in /api
route will fail.
I wish there will be a toggle that says route /api to functions
.
To be more clear here’s what works and what doesn’t:
- nextjs -
/pages/api/hello.js
: works locally, not working in cf pages.- route: [host]/api/hello
- cf function -
/functions/hello.js
: works locally( with wrangler) ,works in cf pages.- route: [host]/api/hello