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.
✘ [ERROR] No routes found when building Functions directory: /opt/buildhome/repo/functions
Warning: Wrangler did not find routes when building functions. Skipping.
✘ [ERROR] No routes found when building Functions directory: /opt/buildhome/repo/functions
Warning: Wrangler did not find routes when building functions. Skipping.
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.
No description
No description
2 Replies
James
James9mo ago
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.
Vikash [Agenty]
Vikash [Agenty]9mo ago
thanks, working now. I was missing export