© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•2y ago
Joshua

Function does not work on deploy (Astro)

I have been reading both the Astro and Cloudflare docs, but I can't solve my problem.

I am trying to print to console on a button press with a Cloudflare function. When using
npx wrangler pages dev -- npm run dev
npx wrangler pages dev -- npm run dev
it does work, but when deployed I get <empty string> in the console and a 404 in the Network tab, even though I can see the functions directory builds (or at least builds without error) correctly. The Cloudflare function logs do not pick up any activity.

What am I doing wrong?

// ASTRO CONFIG
export default defineConfig({
  integrations: [tailwind({
    applyBaseStyles: true
  }), react()],
  output: "server",
  adapter: cloudflare({
    mode: "directory"
  }),
});
// ASTRO CONFIG
export default defineConfig({
  integrations: [tailwind({
    applyBaseStyles: true
  }), react()],
  output: "server",
  adapter: cloudflare({
    mode: "directory"
  }),
});


// CLOUDFLARE ROUTING CONFIGURATION IN CONSOLE

{
  "routes": [
    {
      "routePath": "/helloworld",
      "mountPath": "/",
      "method": "",
      "module": [
        "helloworld.js:onRequest"
      ]
    },
    {
      "routePath": "/:path*",
      "mountPath": "/",
      "method": "",
      "module": [
        "[[path]].js:onRequest"
      ]
    }
  ],
  "baseURL": "/"
}
// CLOUDFLARE ROUTING CONFIGURATION IN CONSOLE

{
  "routes": [
    {
      "routePath": "/helloworld",
      "mountPath": "/",
      "method": "",
      "module": [
        "helloworld.js:onRequest"
      ]
    },
    {
      "routePath": "/:path*",
      "mountPath": "/",
      "method": "",
      "module": [
        "[[path]].js:onRequest"
      ]
    }
  ],
  "baseURL": "/"
}
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

[SSR][Astro] Does it even work
Cloudflare DevelopersCDCloudflare Developers / pages-help
4y ago
next-on-pages data caching does not work
Cloudflare DevelopersCDCloudflare Developers / pages-help
2y ago
Does not work correctly on domains with www
Cloudflare DevelopersCDCloudflare Developers / pages-help
3y ago
service bindings does not work
Cloudflare DevelopersCDCloudflare Developers / pages-help
2y ago