Skip to content

examples: drop redundant WithPermissiveOriginCheck in dev branches (#483) - #107

Merged
adnaan merged 1 commit into
mainfrom
devmode-drop-permissive-origin
Jul 12, 2026
Merged

examples: drop redundant WithPermissiveOriginCheck in dev branches (#483)#107
adnaan merged 1 commit into
mainfrom
devmode-drop-permissive-origin

Conversation

@adnaan

@adnaan adnaan commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What & why

Companion to livetemplate#487. WithDevMode(true) already relaxes the WebSocket origin check to allow all origins, so pairing it with WithPermissiveOriginCheck() in every example's dev branch is redundant. This drops the extra call.

Relies only on already-released v0.18.0 runtime behavior (the docs repo already pins it), so it's independent of the core doc/test PR.

Changes

  • 10 example cmd/main.go: collapse the if *dev { … } branch from a two-call append(WithDevMode(true), WithPermissiveOriginCheck()) to a single WithDevMode(true), with a one-line comment noting dev mode also relaxes the origin check — so a reader copying the example sees the minimal, correct dev setup.
  • 2 test files (live-dashboard/dashboard_test.go, redacted-form/redacted_form_test.go): same redundant pairing in test-built options — dropped.
  • 4 handler.go comments + cmd/site/main.go: rewrote the "test-server callers" notes to describe the mechanism as running in dev mode (which relaxes the origin check) instead of supplying WithPermissiveOriginCheck. These also cited stale e2e paths (docs/e2e/login, docs/e2e/patterns/main.go) that no longer exist — the real callers are the examples' own _test.go files, which launch the app with LVT_DEV_MODE=true via e2etest.StartTestServer.

Verification

  • go build ./examples/... ./cmd/... green; all touched files gofmt-clean.
  • Grepped the whole repo: zero remaining WithPermissiveOriginCheck references.
  • Ran the touched examples' chromedp e2e (browser console + server logs + WS frames + rendered HTML captured): live-dashboard, redacted-form, shared-notepad, todos all pass. The WS upgrade succeeds on a random localhost port in a real browser with WithDevMode(true) alone — e.g. live-dashboard's two-tabs-one-goroutine refresh works over localhost:39817.

🤖 Generated with Claude Code

…483)

WithDevMode(true) already relaxes the WebSocket origin check to allow all
origins (see livetemplate#487), so pairing it with WithPermissiveOriginCheck()
in the dev branch is redundant. Collapse every example's dev branch to a
single WithDevMode(true) call with a comment noting it also relaxes the origin
check — so a reader copying the example sees the minimal, correct dev setup.

Also drop the redundant paired call from the two test files that built their
own options (live-dashboard, redacted-form), and refresh the four handler.go
"test-server callers" comments + cmd/site's to describe the mechanism as
running in dev mode (which relaxes the origin check) rather than supplying
WithPermissiveOriginCheck. Those comments also cited stale e2e paths
(docs/e2e/login, docs/e2e/patterns/main.go) that no longer exist — the real
test-server callers are the examples' own _test.go files, which run the app
with LVT_DEV_MODE=true via e2etest.StartTestServer.

Relies only on already-released livetemplate v0.18.0 runtime behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ZgmyffUen38oazb39RhSk
@adnaan
adnaan merged commit 13a9834 into main Jul 12, 2026
3 checks passed
@adnaan
adnaan deleted the devmode-drop-permissive-origin branch July 12, 2026 15:15
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