How to deploy functions with Pages?
I am working on my 1st CF website and everything works fine on static files, except the
/functions
directory is not deployed for some reason.
When I check the deployment logs on cloudflare dashboard, connected with Github. It says the /functions
directory found but no routes found.
Does that mean, I need to add a _routes.json
to list all the routes?
I was in impression that CF will auto-detect and create routes based on the directory/folder/file
.
Any help will be really appreciated.2 Replies
With functions, you need to export your handlers, instead of adding an event listener like that. See the following docs for details: https://developers.cloudflare.com/pages/platform/functions/get-started/
Get started · Cloudflare Pages docs
This guide will instruct you on creating and deploying a Pages Function.
thanks, working now. I was missing export