Skip to content

Probe the docs site's own origin for chat only when codewiki serve served it - #19

Merged
dandydarshan merged 1 commit into
mainfrom
fix/no-health-probe-on-pages
Nov 7, 2026
Merged

dandydarshan merged 1 commit into
mainfrom
fix/no-health-probe-on-pages

Conversation

@dandydarshan

@dandydarshan dandydarshan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

The viewer probed <its own origin>/api/health before the localhost ports, because when codewiki serve serves the page, the API is on the same origin. On GitHub Pages that probe is always a 404, logged in the browser console every time the chat opens.

 codewiki serve, GET *.html
+  insert <meta name="codewiki-serve" content="1"> right after <head …>   (not <header>)
 viewer chatCandidates
-  if http(s): probe location.origin
+  if <meta name="codewiki-serve">: probe location.origin
   probe the configured 127.0.0.1 ports (unchanged)

Marking the page is what makes this safe. A URL rule like "skip https" would break serve behind an HTTPS proxy or a custom Pages domain. It's compatible both ways: an older serve is still found through the 127.0.0.1 port list, and an older index.html ignores the tag.

Evidence

  • test_a_site_not_served_by_codewiki_does_not_probe_its_own_origin: a static site (like Pages) still probes the localhost ports but never its own /api/health. Fails on the old template.
  • test_serve_marks_the_pages_it_serves: one marker, inside <head lang=en> and not <header>, with non-HTML files untouched. Fails on the old server.
  • The existing Ask AI browser tests, which serve the page through serve and rely on the same-origin path, all pass.
  • 503 tests pass.

Merge Danger

Door: two-way

Blast Radius: chat discovery

A site served by serve --host <non-loopback> relies on the marker; that's the case this PR handles. A site behind a proxy that rewrites HTML and drops <meta> tags would fall back to the localhost ports.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CXRqeijND7XPq2srGHndRd

@dandydarshan
dandydarshan force-pushed the fix/chat-local-network-permission branch from 4b09125 to f1e6d68 Compare November 7, 2026 01:53
@dandydarshan
dandydarshan force-pushed the fix/no-health-probe-on-pages branch from e30e827 to 09aac00 Compare November 7, 2026 01:53
@dandydarshan
dandydarshan deleted the branch fix/chat-local-network-permission November 7, 2026 03:14
@dandydarshan dandydarshan reopened this Nov 7, 2026
@dandydarshan
dandydarshan changed the base branch from fix/chat-local-network-permission to main November 7, 2026 03:14
…rved it

The viewer always probed <its origin>/api/health first, which on GitHub
Pages is a 404 logged in the browser console on every chat open.
`codewiki serve` now marks the HTML it serves with
<meta name="codewiki-serve">, and the viewer probes its own origin only
when that mark is present. Older servers are still found through the
127.0.0.1 port list; older pages ignore the mark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CXRqeijND7XPq2srGHndRd
@dandydarshan
dandydarshan force-pushed the fix/no-health-probe-on-pages branch from 09aac00 to 544a2a3 Compare November 7, 2026 03:19
@dandydarshan
dandydarshan merged commit 7971233 into main Nov 7, 2026
14 checks passed
@dandydarshan
dandydarshan deleted the fix/no-health-probe-on-pages branch November 7, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant