Skip to content

Conversation

@robbie-c
Copy link
Contributor

@robbie-c robbie-c commented May 16, 2025

Fixes #76

Tells webpack not to inject this polyfill, which looks like this (unminified):

/******/ 	/* webpack/runtime/global */
/******/ 	(() => {
/******/ 		__webpack_require__.g = (function() {
/******/ 			if (typeof globalThis === 'object') return globalThis;
/******/ 			try {
/******/ 				return this || new Function('return this')();
/******/ 			} catch (e) {
/******/ 				if (typeof window === 'object') return window;
/******/ 			}
/******/ 		})();
/******/ 	})();

the new Function('return this') part is the bit that will break your CSP rules, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/script-src#unsafe_eval_expressions

@vercel
Copy link

vercel bot commented May 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-json-view ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2025 1:56pm

@Kikobeats
Copy link
Member

wow this a really good catch, thanks for it!

@Kikobeats Kikobeats merged commit 37d1027 into microlinkhq:master May 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Call new Function() which requires unsafe-eval in CSP rules

2 participants