You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is affecting a project I'm working on, but unfortunately that project is not easy to set up. But it's easy to confirm this issue by looking in styled-components' generated dist folder. Any of the generated js files (styled-components.cjs.js is the one I'm using) reveals the problem. This function:
Specifically, the problem is that __webpack_nonce__ becomes window.__webpack_nonce__, and window does not exist server-side. So the returned nonce is null instead of the actual nonce.
The end result is that the browser rejects the style tag (due to CSP), and you get a page of unstyled content.
If it helps, I believe the bug was introduced by #3308. I can confirm that the bug does not exist in v5.2.0, but it does exist in v5.2.1 and every 5.x.x version since.
Expected Behavior
When __webpack_nonce__ is set on the global object, the <style> tag generated by server-side rendering looks like this:
Environment
System:
Binaries:
npmPackages:
Steps to reproduce
This is affecting a project I'm working on, but unfortunately that project is not easy to set up. But it's easy to confirm this issue by looking in styled-components' generated
dist
folder. Any of the generatedjs
files (styled-components.cjs.js
is the one I'm using) reveals the problem. This function:...is transpiled into:
Specifically, the problem is that
__webpack_nonce__
becomeswindow.__webpack_nonce__
, andwindow
does not exist server-side. So the returned nonce isnull
instead of the actual nonce.The end result is that the browser rejects the style tag (due to CSP), and you get a page of unstyled content.
If it helps, I believe the bug was introduced by #3308. I can confirm that the bug does not exist in v5.2.0, but it does exist in v5.2.1 and every 5.x.x version since.
Expected Behavior
When
__webpack_nonce__
is set on the global object, the<style>
tag generated by server-side rendering looks like this:Actual Behavior
Whether or not
__webpack_nonce__
is set on the global object, the<style>
tag generated by server-side rendering looks like this:The text was updated successfully, but these errors were encountered: