fix(route): match page routes case-insensitively like React Router

RA
1d ago
+20-1

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Description

React Router matches route paths case-insensitively by default, so /About renders the page registered at /about. The backend router in reflex/route.py compiled its route regexes case-sensitively and returned no route for that URL. As a result, the page's on_load events did not run, router.page.path was /404, and the production static server answered the SPA fallback with a 404 status.

This change compiles the route regexes with re.IGNORECASE, matching the frontend. Route names are restricted to ASCII letters, digits, _ and -, so the flag has no Unicode side effects.

Testing

  • New test_get_router_ignores_case in tests/units/test_route.py fails on main (4 failed) and passes with the change.
  • uv run pytest tests/units --ignore=tests/units/reflex_cli: 12201 passed, 67 skipped.
  • uv run ruff check, uv run ruff format --check and uv run pyright are clean on the changed files.

Closes #7598