I have been diligently working on an application for quite some time using create-react-app. Recently, I decided to update to the latest version of React only to find out that a new Content Security Policy (CSP) has been implemented.
To my dismay, upon trying to load any page in my app, I am bombarded with 30-40 violations flagged by Chrome devtools. The culprit code is clearly highlighted - here's an example: https://i.sstatic.net/uBp8D.png
The piece of code causing trouble can be found in User.js
and is defined in User.css
. It baffles me why it is rendering in such a way, ultimately leading to a breakage in my CSP.
Just to provide some context, here is what my csp.json
configuration looks like:
{
"dev": {
"default-src": ["'self'", "https://*.googleapis.com"],
"style-src": ["'self'", "https://*.googleapis.com"]
},
"prod": {
"default-src": ["'self'", "https://*.googleapis.com"],
"style-src": ["'self'", "https://*.googleapis.com"],
"connect-src": ["'self'", "https://*.googleapis.com"]
}
}
In Chrome, the source of the issue appears to stem from injectStylesIntoStyleTag.js
.
This mishap has completely disrupted the functionality of my app, leaving me desperate for any helpful suggestions.
Your feedback would be greatly appreciated!