Repository navigation
Conversation
…inks Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
noncerender option for server css links #1528The
<link rel="stylesheet">elements thatrscrenders for server components' CSS, both the auto-injected ones and the ones fromimport.meta.viteRsc.loadCss(), have nononce. A nonce-only CSPstyle-srcblocks them, and a framework has no way to add one.This adds an experimental
setServerCssLinkPropsto@vitejs/plugin-rsc/rsc/server. A framework registers it once, and the plugin calls it while React renders each link, so it can read the nonce from the framework's own request-scoped storage. For now it supports onlynonce.#1528 solves the same problem with a
noncerender option, which the plugin carries to the links through its ownAsyncLocalStorage. Frameworks already keep request state in their ownAsyncLocalStorage, and React renders the links inside the caller's async context either way. So a hook lets the plugin stay out of request scoping entirely, without depending on the globalAsyncLocalStoragethatrsc:inject-async-local-storagesets up for React. The framework then decides which renders get a nonce, for example leaving it out of a render whose output is cached across requests, the same way it already keeps cookies and headers out of cached renders.This still doesn't make a nonce-only
style-srcwork on its own:examples/basicdoesn't, and gives those links no nonce.ReactDOM.preinit, which dropsnoncefor stylesheets.