Before a catch-all route goes live, decide which paths are reserved for fixed pages and which may represent content records. A valid slug is not enough if the router dispatches it to the wrong handler. A 200 response containing the wrong page is still a release failure.
Write a route-to-handler contract for the public namespace. The artifact should identify the expected handler, resource identity and missing-path response for exact inputs. The URL normalization contract concerns equivalent forms of one resource. This exercise concerns competing route meanings and dispatch precedence.
Treat the route table below as a fictional application design, not a universal statement about every framework. Confirm the actual router and version before relying on its precedence rules. Middleware or edge rewrites can alter the path before the application sees it.
Define the fictional blog contract
Assume a fictional site has a fixed /blog/about page, a dynamic article route /blog/[slug],and a separate nested collection namespace under /blog/topics/. The editorial system must reject article slugs that claim reserved fixed names. Unknown articles must return the application’s approved missing-resource response.
The current Next.js dynamic route documentation describes dynamic segments, catch-all arrays and optional catch-all behavior. It also shows validating runtime parameters and using notFound for invalid values. Those definitions explain the kinds of inputs a route can receive;they do not replace a test of this site’s composed router.
Document whether your implementation uses a dynamic segment or a catch-all. A single slug and a multi-segment array are different inputs. Accidentally joining an array into a familiar-looking string can hide an unsupported nested path.
Use exact inputs and expected handlers
The following matrix is the approved behavior for the fictional site. Resource markers are stable test identifiers, not hidden metadata required for search engines. They let the test distinguish two pages that both return 200.
| Input path | Expected handler | Expected result |
|---|---|---|
| /blog/about | Fixed blog information page | 200;marker BLOG_ABOUT |
| /blog/connect-guide | Article lookup | 200;marker ARTICLE_CONNECT |
| /blog/not-a-real-article | Article lookup then missing response | 404;no unrelated article body |
| /blog/topics/security | Topic collection | 200;marker TOPIC_SECURITY |
| /blog/connect-guide/extra | No approved nested article | 404;not truncated to connect-guide |
| /blog/about?view=plain | Same fixed page under this contract | 200;marker BLOG_ABOUT |
The query-bearing row has a deliberately stated policy. Another application might support a real representation variant. Do not discard parameters globally just because this fixture treats one as nonselecting.
Make the content publisher enforce the reservation
Maintain the reserved-name list beside the route configuration or derive it through a documented shared contract. The content validator should reject a new article named about before it reaches production. A warning printed after deployment is too late to prevent the collision.
Add a harmless negative content fixture with the reserved slug. Its build must fail with a concrete conflict message. Then test a permitted slug to show that the validator has not simply disabled article creation. A rule that bans every short word would hide the problem while imposing an unrelated editorial restriction.
If a previously published article already occupies a newly required fixed path, resolve the resource decision before shipping the route. Choose a supported new location and approved migration behavior, or choose another namespace. Do not let framework precedence silently decide which existing public resource disappears.
Test edge rewrites and application dispatch together
A local route unit test may pass while an edge rule rewrites /blog/about into the article handler. Preserve the original request path, the path reaching the application when observable, and the selected resource marker. Test the normal public delivery chain after deployment.
Keep redirects distinct from rewrites. A redirect exposes another URL to the client;an internal rewrite can serve another handler while leaving the requested address unchanged. The latter can produce a plausible canonical URL around the wrong body, which is why handler identity and content checks belong in this matrix.
Record any base path, locale prefix or hosting mount that affects dispatch. Add an explicit fixture when that transformation is part of the supported site. Do not assume the development server’s root mount is the production contract.
Keep missing paths genuinely missing
A broad catch-all sometimes returns the generic blog shell for every unmatched input. Inspect the response status and meaningful body, not just whether the layout rendered. A known invalid nested path should not quietly become the homepage or the first article.
Use the missing-page response review to distinguish the intended missing resource from a successful empty shell. Google’s HTTP status guidance explains why response semantics matter, but the release decision here is under the publisher’s control: serve the right handler and truthful state.
Also inspect generated internal links. If a collection card still links to an old reserved path, the router can be correct while the user journey is wrong. The crawlable navigation contract provides the separate link-level check.
Test the admission rule and runtime lookup separately
A content-admission failure should identify the conflicting reserved path before publication. A runtime lookup failure should identify an unsupported request without inventing a content record. Keep both tests even if the application currently generates routes from one source file;future imports or hosting changes can separate those paths.
For the fictional matrix, attempt to add a synthetic article with slug about and expect validation to reject it. Then request the fixed about page and expect its own marker. Finally request the nonexistent nested article and expect the missing-resource result. These three observations establish different parts of the namespace contract;one cannot stand in for the others.
Release the namespace as a contract
Keep the exact matrix, reserved-name validation, router version, rewrite scope and actual post-release results together. A future developer should be able to add a route without guessing whether a static name is already meaningful to the publication system.
Retain the reserved-slug negative fixture and unsupported nested-path fixture. They catch different regressions: one in content admission, the other in runtime dispatch. Passing only a normal article request proves neither protection works.
Approve when each supported path reaches its intended resource and unsupported paths retain their deliberate missing response. The result is a maintainable namespace boundary, not a claim that adding more route patterns will increase search visibility.
