Cloudflare pages: redirect all posts to a functions

Wordpress forms by default submit all forms to /wp-admin/admin-ajax.php url via post
Now, that url fails, obviously because pages is static.
At the same time I have a function created.
The question: How can make that all calls to /wp-admin/admin-ajax.php be answered by a function?
I was reading about middleware, but I understand middleware applies in all requests, using the 10 million functions request limit.

Some help about the best way ?
Thanks

If you make a Function at functions/wp-admin/admin-ajax.php.js that may work