Skip to content

Conversation

@cdrubin
Copy link
Contributor

@cdrubin cdrubin commented Nov 5, 2025

Validate that no static redirect routes are present in public/__redirects after any dynamic rule has been declared to avoid over shadowing

Summary

The order of application of redirect rules matters. From the documentation:
https://developers.cloudflare.com/pages/configuration/redirects/#per-file:

  • The order of your redirects matter. If there are multiple redirects for the same source path, the top-most redirect is applied.
  • Static redirects should appear before dynamic redirects.

This change helps to enforce these points.

Output on issue

When a static route is found after any dynamic route has been declared the output is similar to the following:

✘ Found static redirect after dynamic redirect:
    /zoo/

Detected errors:
- 1 static redirect(s) after dynamic redirect(s)

and the bin/validate-redirects.ts will return a non-zero (error) code

Documentation checklist

This adds an additional validation to the rules listed in public/__redirects that should be triggered ahead of merging

…ects after any dynamic rule has been declared to avoid over shadowing
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
*.ts @cloudflare/pcx-content-engineering, @kodster28

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

@cdrubin cdrubin merged commit 527ba1c into production Nov 5, 2025
11 checks passed
@cdrubin cdrubin deleted the cefan/validate_no_static_redirects_after_dynamic branch November 5, 2025 17:06
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.

2 participants