From dda197bd8342d5eab6ac75d5cb0bb69397adcf39 Mon Sep 17 00:00:00 2001 From: King Omar Date: Wed, 22 Jul 2026 18:44:55 +1000 Subject: [PATCH] Frontend: run search from root /?q= (redirect to /search?q=) Visiting /?q=what showed the empty home page instead of results because only /search executes a query. Root now redirects a q param to the canonical results URL. Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/src/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/index.ts b/frontend/src/index.ts index 124d380..596e0a3 100644 --- a/frontend/src/index.ts +++ b/frontend/src/index.ts @@ -242,6 +242,14 @@ export default { const url = new URL(req.url) if (url.pathname === '/') { + // Accept a query on the root too (e.g. /?q=what) — redirect to the + // canonical results URL so the search actually runs. + const q = url.searchParams.get('q')?.trim() + if (q) { + const page = url.searchParams.get('page') + const dest = `/search?q=${encodeURIComponent(q)}${page ? `&page=${encodeURIComponent(page)}` : ''}` + return Response.redirect(url.origin + dest, 302) + } return new Response(homePage(), { headers: { 'Content-Type': 'text/html; charset=utf-8' } }) }