docs: exempt patterns from cf _routes.json#2136
Conversation
Deploying nuxt-image with
|
| Latest commit: |
658a264
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fd30ee6f.nuxt-image.pages.dev |
| Branch Preview URL: | https://docs-prerender.nuxt-image.pages.dev |
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2136 +/- ##
========================================
- Coverage 6.83% 6.82% -0.01%
========================================
Files 80 80
Lines 3732 3737 +5
Branches 142 142
========================================
Hits 255 255
- Misses 3427 3432 +5
Partials 50 50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
_routes.json
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/nuxt.config.ts`:
- Around line 13-21: The exclude list in the Nuxt config currently uses patterns
like '/usage/*' which do not match the parent landing pages (e.g., '/usage');
update the exclude array (the one defined in docs/nuxt.config.ts) to include
explicit parent route entries for each section (add '/get-started', '/usage',
'/providers', '/advanced', '/playground', '/__og-image__', '/__nuxt_content',
'/raw' alongside the existing wildcard patterns) so the section landing pages
are also excluded by Cloudflare Pages routing.
| exclude: [ | ||
| '/get-started/*', | ||
| '/usage/*', | ||
| '/providers/*', | ||
| '/advanced/*', | ||
| '/playground', | ||
| '/__og-image__/*', | ||
| '/__nuxt_content/*', | ||
| '/raw/*', |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Nitro cloudflare.pages.routes.exclude wildcard pattern matching documentation
💡 Result:
In Nitro’s Cloudflare Pages preset, nitro.cloudflare.pages.routes.exclude is used to generate/override the Cloudflare Pages _routes.json exclude list, so the wildcard behavior is whatever Cloudflare Pages supports in _routes.json. In practice, treat these as Cloudflare Pages route globs, not regex. [1]
Wildcard matching rules (Cloudflare Pages _routes.json)
- Only the
*wildcard is used. excludeandincludeentries accept wildcards.excludealways takes priority overinclude.*matches any number of path segments (including/). Example:/users/*matches everything after/users/. [1]
Example (Nitro config)
export default defineNuxtConfig({
nitro: {
cloudflare: {
pages: {
routes: {
exclude: [
"/docs/*",
"/blog/*",
],
},
},
},
},
})This is commonly used to avoid generating huge per-page excludes (Cloudflare Pages has a 100-route limit), by excluding entire pre-rendered sections via wildcards. [2]
Sources: Cloudflare Pages routing / _routes.json wildcard behavior [1]; NuxtHub recipe showing nitro.cloudflare.pages.routes.exclude usage [2].
🏁 Script executed:
# Search for Nitro configuration examples in the codebase
fd -t ts -t js nitro.config | head -20Repository: nuxt/image
Length of output: 223
🏁 Script executed:
# Search for cloudflare pages configuration patterns in docs
rg "cloudflare.pages" --type ts --type js -A 5 -B 2 | head -100Repository: nuxt/image
Length of output: 36
Add explicit parent route patterns to exclude section landing pages.
Per Cloudflare Pages _routes.json documentation, the * wildcard in patterns like /usage/* matches "everything after /usage/", meaning it excludes only child routes, not the parent route itself (e.g., /usage). Section landing pages will not be excluded as intended without explicit parent route entries.
Suggested fix
routes: {
exclude: [
+ '/get-started',
'/get-started/*',
+ '/usage',
'/usage/*',
+ '/providers',
'/providers/*',
+ '/advanced',
'/advanced/*',
'/playground',
'/__og-image__/*',
'/__nuxt_content/*',
'/raw/*',
],
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| exclude: [ | |
| '/get-started/*', | |
| '/usage/*', | |
| '/providers/*', | |
| '/advanced/*', | |
| '/playground', | |
| '/__og-image__/*', | |
| '/__nuxt_content/*', | |
| '/raw/*', | |
| exclude: [ | |
| '/get-started', | |
| '/get-started/*', | |
| '/usage', | |
| '/usage/*', | |
| '/providers', | |
| '/providers/*', | |
| '/advanced', | |
| '/advanced/*', | |
| '/playground', | |
| '/__og-image__/*', | |
| '/__nuxt_content/*', | |
| '/raw/*', |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/nuxt.config.ts` around lines 13 - 21, The exclude list in the Nuxt
config currently uses patterns like '/usage/*' which do not match the parent
landing pages (e.g., '/usage'); update the exclude array (the one defined in
docs/nuxt.config.ts) to include explicit parent route entries for each section
(add '/get-started', '/usage', '/providers', '/advanced', '/playground',
'/__og-image__', '/__nuxt_content', '/raw' alongside the existing wildcard
patterns) so the section landing pages are also excluded by Cloudflare Pages
routing.
🔗 Linked issue
❓ Type of change
📚 Description
this works around an issue in CF pages, which has a limit of 100 static pages, so the ~239 prerendered pages/files in this build were getting silently truncated, which was why nuxt-picture and use-img were returning 404s (we couldn't render them via SSR)
cc: @pi0 @larbish