Skip to content

fix: pass nonce to importmap script when using subResourceIntegrity#14675

Merged
brophdawg11 merged 6 commits intoremix-run:devfrom
dimmageiras:fix/nonce-importmap-subresource-integrity
Dec 23, 2025
Merged

fix: pass nonce to importmap script when using subResourceIntegrity#14675
brophdawg11 merged 6 commits intoremix-run:devfrom
dimmageiras:fix/nonce-importmap-subresource-integrity

Conversation

@dimmageiras
Copy link
Contributor

@dimmageiras dimmageiras commented Dec 19, 2025

Description

When unstable_subResourceIntegrity is enabled, the importmap script tag was missing the nonce attribute, causing CSP violations when strict Content Security Policy is enforced without 'unsafe-inline'.

This fix ensures the nonce attribute is properly passed to the importmap script element, allowing applications to use strict CSP policies.

Changes

  • packages/react-router/lib/dom/ssr/components.tsx: Added nonce={scriptProps.nonce} to the importmap script element

Impact

  • Fixes CSP compatibility issue with subResourceIntegrity feature
  • Allows applications to use strict CSP policies without unsafe-inline
  • No breaking changes - only adds missing nonce attribute

Fixes #14252

When unstable_subResourceIntegrity is enabled, the importmap script tag
was missing the nonce attribute, causing CSP violations when strict
Content Security Policy is enforced without 'unsafe-inline'.

This fix ensures the nonce attribute is properly passed to the importmap
script element, allowing applications to use strict CSP policies.

Fixes remix-run#14252
@changeset-bot
Copy link

changeset-bot bot commented Dec 19, 2025

🦋 Changeset detected

Latest commit: a28ae1a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Dec 19, 2025

Hi @dimmageiras,

Welcome, and thank you for contributing to React Router!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Dec 19, 2025

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@brophdawg11
Copy link
Contributor

Thanks! Can you add a changeset file to the branch via pnpm changeset?

@dimmageiras dimmageiras force-pushed the fix/nonce-importmap-subresource-integrity branch from cbcf4b7 to 7888e17 Compare December 22, 2025 20:18
@dimmageiras
Copy link
Contributor Author

Thanks! Can you add a changeset file to the branch via pnpm changeset?

I hope I did it properly

@brophdawg11 brophdawg11 merged commit cbcbf30 into remix-run:dev Dec 23, 2025
8 of 9 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

🤖 Hello there,

We just published version 7.12.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🤖 Hello there,

We just published version 7.12.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@dimmageiras dimmageiras deleted the fix/nonce-importmap-subresource-integrity branch January 13, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants