Use of `eval` in development mode violates Content-Security-Policy
See original GitHub issueVersion
4.4.0-beta.7
Test Case
CodeSandbox doesn’t support adding CSP, but it would look like this:
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline';" />
</head>
<body>
<div id="root"></div>
<script src="index.js"></script>
</body>
</html>
Steps to reproduce
Import react-router in some file, launch app in development mode.
Expected Behavior
Things loading fine with CSP enabled.
Actual Behavior
Browser blocks execution of react-router.js because it uses eval:
Is there a way of implementing your current logic without eval?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Use of `eval` in development mode violates Content-Security ...
Import react-router in some file, launch app in development mode. Expected Behavior. Things loading fine with CSP enabled. Actual Behavior.
Read more >How to fix 'because it violates the following content security ...
Content Security Policy blocks all resources that don't match it's policy. To view the policy for a specific website use the CSP Evaluator....
Read more >Content security policy - web.dev
This is a great way to evaluate the effect of changes to your application's CSP: turn on reporting for a new policy, monitor...
Read more >Webpack dev server React Content Security Policy error
If you use Webpack in your project, please add output.publicPath = '/' and devServer.historyApiFallback = true in your webpack config file.
Read more >Use Tag Manager with a Content Security Policy
They can be used to create custom tags and variables that do not require the use of 'unsafe-eval' . Preview Mode. In order...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Having the same issue, I was about to report it as well. It was introduced here
https://github.com/ReactTraining/react-router/blob/b2c6fa0725b7ff1ed762064d633b26b6293e0140/packages/react-router/modules/index.js#L1-L20
@mjackson what was the reason for using
eval?@mjackson verified on my app, this is working perfectly. Thank you!