#3402·fresh

Unable to deploy Fresh to Cloudflare Workers

Author: 4x25Created Sep 12, 2025Updated Jun 24, 2026
Labelsupstream

Hi, I'm trying to deploy a Fresh project to Cloudflare Workers, but I've been unsuccessful.

Here are the steps I followed:

  1. I created a new project using the following command:

    deno run -Ar jsr:@fresh/init
  2. I followed the Cloudflare Workers | Fresh docs and added the required code to vite.config.ts file.

  3. I added a wrangler.jsonc file with the following content:

    jsonc
    {
      "$schema": "node_modules/wrangler/config-schema.json",
      "name": "fresh2-example",
      "main": "./main.ts",
      "compatibility_date": "2025-04-01",
      "compatibility_flags": ["nodejs_compat"],
      "observability": {
        "enabled": true
      },
      "upload_source_maps": true
    }
  4. I added the following code to the end of my main.ts file:

    typescript
    export default {
      fetch: app.handler(),
    };
  5. I pushed the project to a GitHub repository, which you can find here: mzl980425/fresh2-example. Then, I created a new Worker on Cloudflare and connected it to this repository. The worker's build configuration is as follows:

    • Build command: npx deno task build
    • Deploy command: npx wrangler deploy
  6. After the deployment was complete, I found that static assets are served correctly (e.g., https://xxx.workers.dev/favicon.ico, https://xxx.workers.dev/logo.svg). However, all other page and API routes return a "NOT FOUND" error, including the root page (https://xxx.workers.dev/) and API routes like (https://xxx.workers.dev/api2/world).

Is there something wrong with my code or configuration? Any help would be greatly appreciated.

Thanks