Unable to deploy Fresh to Cloudflare Workers

Aperta
#3,402 14 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
deno, typescript
Ambito
api, backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
13.8k
Fork
757
Merge medio
3m
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di freshframework/fresh

Tutte le issue di freshframework/fresh

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.