Skip to main content

Bug fix: clicking a module now opens the right page

· One min read
Pratyush
Site maintainer

Clicking any module card was silently redirecting to the homepage. Fixed.

What was broken

Navigating to /modules/8/ (or any module by path) loaded the homepage instead of Module 8. No error, no message — just the wrong page.

Root cause

Cloudflare Pages has an SPA fallback: any path that doesn't match a real file gets served index.html from the root. So /modules/8/ had no matching file, fell through to the root index.html, and that's all you saw.

The _redirects rule meant to catch this was never reached — the SPA fallback fires first.

Fix

Switched from path-based routing to query-string routing:

BeforeAfter
/modules/8//modules/?m=8

Query-string URLs always resolve to /modules/index.html, which exists — so the SPA fallback never triggers. The page then reads ?m=8 from URLSearchParams and renders the right module.

Clean, reliable, no build step needed.