score:281
For me it was because of the Chrome extension 'Grammarly'. After disabling that, I did not get the error.
score:-1
In my case, I deleted src/registerServiceWorker file from create-react-app generated app. I added it and now it's all working.
score:0
If your project is vue-cli and you run npm run build
you should change
assetsPublicPath: '/'
to assetsPublicPath'./'
score:0
I had the same issue and it turns out there was an error in the directory of the file I was trying to serve instead of:
app.use(express.static(__dirname + '/../dist'));
I had :
app.use(express.static('./dist'));
score:0
I also faced the same issue today in my running code. Well, I found a lot of answers here. But the important thing I want to mention is that this error message is quite ambiguous and doesn't explicitly point out the exact error.
Some faced it due to browser extensions, some due to incorrect URL patterns and I faced this due to an error in my formGroup instance used in a pop-up in that screen. So, I would suggest everyone that before making any new changes in your code, please debug your code and verify that you don't have any such errors. You will certainly find the actual reason by debugging.
If nothing else works then check your URL as that is the most common reason for this issue.
score:0
In my laravel & VueJS project I solved this error with webpack.mix.js file. It contains
const mix = require('laravel-mix');
mix.webpackConfig({
devServer: {
proxy: {
'*': 'http://localhost:8000'
}
},
resolve: {
alias: {
"@": path.resolve(
__dirname,
"resources/assets/js"
)
}
}
});
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
score:0
Running my frontend application on a different port worked for me.
Initially I had ng serve --port 3000
which I later changed to ng serve --port 5000
score:0
if it says report only, refused to execute content policy error. Then the warning can be ignored and it may be caused by the page shield feature on cloudflare.
score:1
You would have used inline styles at many places, which CSP(Content Security Policy) prohibits because it could be dangerous.
Just try removing those inline styles and put it inside dedicated stylesheet.
score:1
I had the same problem and which got resolved by using ./
before the directory name in my node.js
app, i.e.
app.use(express.static('./public'));
score:1
Here is a part of code I use to direct my server.js file to angular dist folder, which was created after npm build
// Create link to Angular build directory
var distDir = __dirname + "/dist/";
app.use(express.static(distDir));
I fixed it by changing
"/dist/"
to "./dist/"
score:1
For me it was because of ipfs extension in brave browser
score:2
I had a similar issue. I had mentioned a wrong output folder path in angular.json
"outputPath": "dist/",
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist/index.html'));
});
score:2
The browser extension uBlock’s setting “Block remote fonts” will cause this error. (Note: Grammarly was not the problem, at least for me.)
Usually this isn’t a problem. When a remote font is blocked, you fall back to some other font and a console warning saying “ERR_BLOCKED_BY_CLIENT” is issued. However, this can be a serious problem when a site uses Font Awesome, because the icons show as boxes.
There’s not much a website can do about fixing this (but you can prevent it from being too bad by e.g. labeling font-based icons). Changing the CSP (or adding one) will not fix it. Serving the fonts from your website (and not a CDN) will not fix it either.
The uBlock user, on the other hand, has the power to fix this by doing one of the following:
- Uncheck the option globally in the dashboard for the extension
- Navigate to your website and click on the extension icon, then on the crossed out ‘A’ icon to not block fonts just for that site
- Disable uBlock for your site by adding it to the whitelist in the extension’s dashboard
score:3
CSP helps you whitelisting sources that you trust. All other sources are not allowed access to. Read this Q&A carefully, and then make sure that you whitelist the fonts, socket connections and other sources if you trust them.
If you know what you are doing, you can comment out the meta
tag to test, probably everything works. But realise that you / your user is being protected here, so keeping the meta
tag is probably a good thing.
score:3
I was also facing the same error in my node application today.
Below was my node API.
app.get('azureTable', (req, res) => {
const tableSvc = azure.createTableService(config.azureTableAccountName, config.azureTableAccountKey);
const query = new azure.TableQuery().top(1).where('PartitionKey eq ?', config.azureTablePartitionKey);
tableSvc.queryEntities(config.azureTableName, query, null, (error, result, response) => {
if (error) { return; }
res.send(result);
console.log(result)
});
});
The fix was very simple, I was missing a slash "/" before my API. So after changing the path from 'azureTable' to '/azureTable', the issue was resolved.
score:5
I was facing similar issue.
- You need to remove all the CSP parameter which are picked up by default and understand why each attribute is required.
font-src - is to tell the browser to load the font's from src which is specified after that. font-src: 'self' - this tells to load font family within the same origin or system. font-src: 'self' data: - this tells load font-family within the same origin and the calls made to get data:
You might also get warning "** Failed to decode downloaded font, OTS parsing error: invalid version tag **" Add the following entry in CSP.
font-src: 'self' font
This should now load with no errors.
score:11
You may need to add this to webpack.config.js
:
devServer: {
historyApiFallback: true
}
score:16
From personal experience, it is always a best, first step to run your site in Incognito (Chrome), Private Browsing (Firefox), and InPrivate (IE11 && Edge) to remove the interference of add-ons/extensions. These can still interfere with testing in this mode if they are enabled explicitly in their settings. However, it is an easy first step to troubleshooting an issue.
The reason I am here, was due to Web of Trust (WoT) adding content to my page, and my page having had very strict Content Security Policy:
Header set Content-Security-Policy "default-src 'none'; font-src 'self' data:; style-src 'self' 'unsafe-inline' data:; img-src 'self' data:; script-src 'self' 'unsafe-inline'; connect-src 'self';"
This caused many errors. I was looking more for an answer on how to tell the extension to not try and run on this site programatically. This way when people have extensions, they just won't run on my site. I imagine if this were possible, ad blockers would have been banned on sites long ago. So my research is a bit naive. Hope this helps anyone else trying to diagnose an issue that is not specifically tied to the handful of mentioned extensions in other answers.
score:27
For what it's worth - I had a similar issue, assuming it's related to a Chrome update.
I had to add font-src, and then specify the url because I was using a CDN
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; font-src 'self' data: fonts.gstatic.com;">
score:94
To fix this specific error, CSP should include this:
font-src 'self' data:;
So, index.html meta should read:
<meta http-equiv="Content-Security-Policy" content="font-src 'self' data:; img-src 'self' data:; default-src 'self' http://121.0.0:3000/">
Source: stackoverflow.com
Related Query
- Refused to load the font 'data:font/woff.....'it violates the following Content Security Policy directive: "default-src 'self'". Note that 'font-src'
- Error: Refused to load the script because it violates the following Content Security Policy directive: "default-src 'none'"
- create-react-app issue: Refused to load the image '<URL>' because it violates the following Content Security Policy directive:
- Refused to load the script 'https://apis.google.com/js/platform.js' because it violates the following Content Security Policy
- Refused to connect to 'ws://localhost:3000/cpp' because it violates the following Content Security Policy directive:
- Inline script because it violates the following Content Security Policy directive: "script-src 'self'"
- Helmet causing MERN app hosted on heroku cause ERROR: Refused to execute inline script because it violates the following
- Image violates the following Content Security Policy directive - Create React App
- React Service worker: Load new content without forcing user to close the tab
- Refused to load the image 'https://diary2020.herokuapp.com/favicon.ico'
- React page doesn't load the new content
- Type 'Element' is missing the following properties from type 'ButtonProps': className, content
- How to adjust the font size based on the content (which is a number and string) in a container?
- Reactjs does not load the text font
- How to fix internal server error 500 and refused to load image because of content security policy?
- Type 'Element[]' is missing the following properties from type 'Element': type, props, key
- React with Typescript - Type { } is missing the following properties from type
- Next.js background-image css property cant load the image
- failed to load response data request content was evicted from inspector cache
- Mocking react-router-dom for useHistory hook causes the following error - TS2698: Spread types may only be created from object types
- React Use RouteComponentProps - Type '{}' is missing the following properties from type 'Readonly<RouteComponentProps<{}
- How to load more search results when scrolling down the page in React.js?
- How to fix "Type '{}' is missing in the following properties..." error in Typescript?
- Why adding a <script> tag at runtime doesn't load the javascript file? (with react.js)
- material UI - How can I change the font size of the label in FormControlLabel
- How do I display the content of React Quill without the html markup?
- How i can limit the items in the FlatList and add load more?
- Test the content of an <iframe> in a React component with Enzyme
- How to load the google maps api <script> in my react app only when it is required?
- Listen to event fired when the content has changed in CKEditor 5
More Query from same tag
- Are these two logical operator conditions same?
- Material ui - change the height of the Accordion
- What constitutes an appropriate use of ref in React
- post.frontmatter.title.filter is not a function
- Where to fetchRecords in React - componentDidMount or onComponentDidUpdate or else where?
- Issue in mapping arrays
- Issues with CSRF on login form with React SPA and Django
- NextJS: Do I need to use getInitialProps with next-redux-wrapper to share state to all pages?
- Redux thunk: how to await completion of an async action
- Using nested folders with react-rails prerender
- this.props.match.params.id in React.js is undefined
- How can I detect if a @lexical/react editor is focused?
- Download more than 80MB of data using Axios
- How to fix 'Cannot set property 'props' of undefined' error
- stateless component doesn't receive new props after action
- pass both props and a state object and let child component move parent component
- Export to excel with React and SheetJS
- Posting data to Firebase (React)
- Jest snapshot test adds a "_class" word into React HOC in snapshot on CI but not on my machine
- How to replay a CSS3 animation in Reactjs
- How to use useState in addEventListener?
- React VictoryPie - How to scale slice on mouse hover
- React-Redux state lost after refresh
- How to fix require.ensure error Webpack, Babel6, React?
- Why shouldComponentUpdate hook is not working in React?
- Why aren't my props available to use in my component when I need them?
- Passing number type as React component property
- React async data (object) getting corrupted while assigned to state
- React - display post details
- want to increase previous and next page pagination icon size in material react table