Skip to content

[Pages] Document wildcards before a file extension in _routes.json - #33566

Open
zkousama wants to merge 2 commits into
cloudflare:productionfrom
zkousama:pages-routes-extension-wildcard
Open

zkousama wants to merge 2 commits into
cloudflare:productionfrom
zkousama:pages-routes-extension-wildcard

Conversation

@zkousama

Copy link
Copy Markdown

Summary

The _routes.json section says wildcards match any number of path segments, and every example puts the wildcard at the end of a rule (/users/*, /build/*). A wildcard also works before a file extension, which the page doesn't say: /api/*.json excludes every .json file under /api/, at any depth.

It's the rule a project needs when static files and Function routes share a path, like an API that serves pre-rendered .json files beside routes a Function answers. With only trailing wildcards to go on, the rule that looks available is /api/*, and that sends every static file under /api/ through the Function.

This adds that case as a third example, and fixes a missing space in the wildcard note.

I checked the behaviour on a Pages project before documenting it, with "include": ["/api/*"], "exclude": ["/api/*.json"] and a catch-all Function in functions/api/[[path]].js:

/api/communes/01.511.01.0.json              static file
/api/communes/01.511.01.0/indicators.json   static file
/api/communes/tanger                        Function
/api/communes/tanger/indicators             Function
/api/search                                 Function

Documentation checklist

@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Review

⚠️ Part of the review could not complete in commit f5e1426 — it will retry on the next push.

Code Review

This code review is in beta and may not always be helpful — use your judgment.

No code review issues found.

Conventions

❌ This review could not complete this run; results may be incomplete. It will retry on the next push.

Style Guide Review

No style-guide issues found.

Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.
/ignore-review-limit Permanently lifts the 2-review automatic limit for this PR. Future pushes will trigger reviews as normal.
/disable-auto-review Stops automatic reviews from triggering on future pushes to this PR. Codeowners can still run /review or /full-review manually.
/rebase Rebases the PR branch against production. On conflict, attempts to resolve automatically using AI. Stops with an explanation if confidence is not high enough.

@cloudflare-docs-bot

Copy link
Copy Markdown
Contributor

Review coverage

🟡 1 ownership area needs approval.

Suggested reviewers: @GregBrimble @irvinebroque

Needs approval Eligible approvers Suggested
pages @aninibread, @GregBrimble, @irvinebroque, @MattieTK, @scottbuscemi, @WalshyDev, @cloudflare/product-owners GregBrimble, irvinebroque
CODEOWNERS mappings for displayed areas (1)
Pattern Owners
/src/content/docs/pages/ @aninibread, @GregBrimble, @irvinebroque, @MattieTK, @scottbuscemi, @WalshyDev, @cloudflare/product-owners

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant