Skip to content

docs(security): resolve the page nonce snippets' URLs as the browser sends them - #830

Merged
JuroOravec merged 1 commit into
mainfrom
docs/page-nonce-snippet-base-url
Nov 21, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
docs/page-nonce-snippet-base-url

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

(Opus 5.5)

Tightens the two docs snippets that send Citry.pageNonce() in the X-Citry-Page-Nonce header (added in #822, not yet in a package release):

  • htmx snippet (security.md, Nonces in fragments): htmx resolves a relative path against the page's base URL, so the snippet now checks the path's origin against both document.baseURI and location.href, and sends no nonce when the path is not a valid URL.
  • fetch() example (reference/browser-apis.md): builds the URL from location.href and passes redirect: "error".
  • Both pages say that a redirect on the site's own origin passes the header on, and how to limit the htmx snippet to fragment paths.

Review: an independent reviewer checked both snippets in Chromium with htmx 2.0.10: <base> tags, path forms (//, /\\, \\\\, absolute, javascript:, empty), elements named baseURI or with id Citry, selfRequestsOnly on and off. All safe with the new snippets. It also swept Citry's browser code (resolveOnPage, Events and i18n fetches, csrfHeaders); nothing to change. Its redirect recommendation is folded in. Prose pass: no findings.

Docs only; no package change. Lands before the citry 1.2.0 publish so the 1.2.0 docs snapshot carries it.

🤖 Generated with Claude Code

https://claude.ai/code/session_017pjjQc1w8PkP2VuK3qFsKw

…sends them

The htmx snippet now checks the request path against the page's base URL
as well as its address, and the fetch() example builds its URL from
location.href and refuses redirects. Both pages say how a redirect on the
site's own origin passes the header on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017pjjQc1w8PkP2VuK3qFsKw
@JuroOravec
JuroOravec merged commit d0adc42 into main Nov 21, 2026
18 of 21 checks passed
@JuroOravec
JuroOravec deleted the docs/page-nonce-snippet-base-url branch November 21, 2026 16:26
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