unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.91k stars 497 forks source link

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

Open Barbapapazes opened 8 months ago

Barbapapazes commented 8 months ago

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

Brendonovich commented 4 months ago

I've had this fixed on our fork for a while and it's been working well, I'll get it rebased on main and open a PR.

pgraug commented 4 months ago

Hi! Sorry I missed this issue when making #2319.

If you add you own wildcard excludes to the config, Nitro already omits all paths matching that from being added again. It's a little bit of manual work, but may avoid some of the possible edge-case complexity of auto-generating the wildcard excludes.

Either way more documentation of this would probably help.