Unable to deploy Fresh to Cloudflare Workers

Open
#3,402 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
deno, typescript
Domain
api, backend

Research direction

Start with the Cloudflare Workers deployment docs and the reporter's vite.config.ts, main.ts, and wrangler.jsonc configuration. Reproduce the deployment using the linked example repository, then trace why static assets work while page and API routes return “NOT FOUND.” The issue is resolved when those routes work on the deployed Worker.

Written by the indexing model from the issue text.

Description

upstream

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:

    {
      "$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:

    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

Dominant language
TypeScript
Stars
13.8k
Forks
757
Avg merge
3m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from freshframework/fresh

All issues in freshframework/fresh

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.