Skip to content

Fix CSP nonce hydration mismatch in ShopifyScripts#3857

Open
AboodFares wants to merge 1 commit into
Shopify:previewfrom
AboodFares:fix/shopify-scripts-nonce-hydration-mismatch
Open

Fix CSP nonce hydration mismatch in ShopifyScripts#3857
AboodFares wants to merge 1 commit into
Shopify:previewfrom
AboodFares:fix/shopify-scripts-nonce-hydration-mismatch

Conversation

@AboodFares

Copy link
Copy Markdown

Browsers hide a parsed script's nonce content attribute (exposing nonce="" while the real value stays on the .nonce property), which React reported as an attribute mismatch on the external generated script on every full page load when a CSP nonce was used. Suppress this known, benign diff for generated script tags when a nonce is supplied. Inline scripts were already covered via their innerHTML branch.

Fixes #3855

WHY are these changes introduced?

Fixes #0000

WHAT is this pull request doing?

HOW to test your changes?

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or functional changes. Test changes or internal-only config changes do not require a changeset.
  • I've added tests to cover my changes
  • I've added or updated the documentation

Browsers hide a parsed script's nonce content attribute (exposing
nonce="" while the real value stays on the .nonce property), which React
reported as an attribute mismatch on the external generated script on
every full page load when a CSP nonce was used. Suppress this known,
benign diff for generated script tags when a nonce is supplied. Inline
scripts were already covered via their innerHTML branch.

Fixes Shopify#3855

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@AboodFares
AboodFares requested a review from a team as a code owner July 14, 2026 17:56
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