nitrojs / nitrojs/nitro

Too many items generated in `_route.json` for cloudflare preset

Open
#2,068 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug preset:cloudflare v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Environment

/

Reproduction

Run playground from repo unsing

NITRO_PRESET=cloudflare_pages nr dev:build
Describe the bug

Actually, the preset use a glob to add every files from the public directory https://github.com/unjs/nitro/blob/main/src/presets/cloudflare-pages.ts#L113. This can easily generate more than 100 paths, limit from Cloudflare, https://developers.cloudflare.com/pages/functions/routing/#limits.

Could we add a flag to generate global path like '/assets/', '/images/' and so on?

related to https://github.com/nuxt-modules/og-image/issues/77
related to https://github.com/unjs/website/pull/228#issuecomment-1884945571

Additional context

No response

Logs

No response

Contributor guide

Open the contributing guide

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.

Research direction

Start in src/presets/cloudflare-pages.ts around the referenced glob at line 113, then run the playground command with NITRO_PRESET=cloudflare_pages nr dev:build. Trace how public files become _route.json entries and define what grouped wildcard paths should look like; done means the generated routes stay within Cloudflare Pages' limit while preserving public asset routing.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.