Cloudflare Page Functions - No route (

Hey all, I’ve followed the docs and examples from ( and and have a cloudflare-enabled astro site deployed. However, when I add the root level functions directory (along with a single endpoint) and try to call the endpoint (from index.astro ) I’m getting 500 server errors. I’m assuming it’s because there’s no entry in the generated _routes.json file:

  "version": 1,
  "include": [
  "exclude": []

Any ideas?

Cloudflare page:

You haven’t specified the deployment mode in your Cloudflare integration config, it means the default “advanced” mode is used which means your “functions” folder is disregarded - Astro compiles code in ./src folder and generates _worker.js file in the dist folder which is being deployed.

If you want to specify your functions in ./functions folder, make sure to specify directory mode

1 Like

Much appreciated @antipov.alexei - thank you for explaining. Other than the config setting you mentioned I also had to change the fetch API endpoint in my astro file to the wrangler URL (http://localhost:8788/api/echo) in dev mode. Once set, this all worked locally.

When it comes to deployment however if I revert the url back to /api/echo, build, and redeploy I get a 500 error.

New preview url is

Edit: (fixed incorrect url )

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.