-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nonce to vite_react_refresh_tag
Rails tag helper
#249
Comments
Hi Renaud, thanks for reporting. Ideally, we add a new PRs are welcome! |
vite_react_refresh_tag
does not support CSP noncesvite_react_refresh_tag
Rails tag helper
Hey, just wondering if there's been any progress on this. We're looking to get CSP enabled and this is obviously blocking the more advanced CSP cases. |
This only affects development, where you can make an exception if needed.
|
Description 📖
When using a Content Security Policy that does not allow
unsafe-inline
scripts,vite_react_refresh_tag
does not work as inline JS is not allowed. The solution is to enable CSP nonces (Rails has a way to do it), but then the nonce is not added to the generated<script>
tag and the tag is ignored.Note that this is quite common policy using nonces or script hashes, needed for the legacy plugin for example
Solution 💡
I see 2 solutions here, and I can try a PR to implement the one you prefer:
react_refresh_preamble
to only return the JS content, and wrap it into the framework specific tag for each framework, allowing to pass framework options as needed (for examplevite_react_refresh_tag(nonce: true)
)vite_react_refresh_tag
andreact_refresh_preamble
to accept anonce
argument, and add it to the generated HTMLWhat do you think?
The text was updated successfully, but these errors were encountered: