Closed maathi closed 6 years ago
@mehdi-desu it looks like the CSS files are loaded as HTML instead of Stylesheets. It appears to be something like this: https://stackoverflow.com/questions/48248832/stylesheet-not-loaded-because-of-mime-type.
As this shows up a lot in Google Search results I thought I'd share that in similar projects this appears to be due to the inclusion of HBP5 directives for Nginx.
If the extra security file below is included, then stylesheets being served through proxies such as webpack will fail to load due to CSP. See the notes on Line 17 below
https://github.com/h5bp/server-configs-nginx/blob/master/h5bp/directive-only/extra-security.conf
Although this setting has been in HBP5 configs for a while, webkit browsers have only just started enforcing it. Hope this helps others
@mehdi-desu did you solve your issue?
Having same issue Refused to apply style from...styles.f4fb5cb8ad4ea5bce7fb.bundle.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Add <base href="/">
in head before linking all css files
Did you solve the issue?
in my case I already had
The issue is not resolved http://prntscr.com/jecsmv
@connect2amitu you saved my day here :) I was having this problem with react and react router running with webpack-dev-server and <base href="/">
does the trick.
@connect2amitu
@connect2amitu it doesn't work for me
@connect2amitu this trick worked ,thanks a lot!
<base href="/">
Worked for me, thanks!!
I think the root cause of the issue is that the minified css has comments in them. Check out https://stackoverflow.com/questions/48248832/stylesheet-not-loaded-because-of-mime-type
I think the root cause of the issue is that the minified css has comments in them
minified css does not contain comments.
I have faced the issue as well, in my case, the css file was missing, but defined in HTML
I do not think that the content of the css
matters. For example, in my index.html
, I tried replacing the Material Icons css with a local version as follows:
<!--<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">-->
<link rel="stylesheet" type="text/css" href="google_material.css">
I get the same error when the google_material.css
is blank!
I was using Node npm module on my project without angular frameworks. I m using Embedded JavaScript templates (EJS). I added new folders and it keeps showing error loaded of CSS style and js files, so I have decided to put into head.html
<base href="/"
Those are solved problems. thank you!
Having the same issue currently.
i have same issue .i have tried this much but still img is not getting load.what should i do?
<!-- <img [src]="fullImagePath" alt="suyog" class="img-fluid"> -->
<img src="/suyog.jpg" alt="suyog" class="img-fluid">
i have saved photo in c folder.how to give path?
Not sure if this will help anyone, but if you are using angular-cli, I fixed this by removing the css reference from my index.html and adding it to the angular-cli.json file under the "style" portion. After restarting my webserver I no longer had that issue.
Adding <base href="/">
before linking the stylesheets didn't work for me, but taking the rel property off the <link>
tag did work:
<link rel="stylesheet" href="styles.css" type="text/css"> Produces Error
<link href="styles.css" type="text/css"> No error
@Rich0101 The error disappears but the styles are not applied unfortunately :confused:
Just add type="text/html" Like this
@Rich0101 your trick works for me, even with comments in my css.
@ovidiup13 debug your page in chrome, probably there's a css overriding your style. I'm using Angular Material and I wanted to make the button's font smaller, so what I did is explicitly have css for the entire body and manipulate mat-button like this
.body-container .mat-button { font-size: small !important; }
It works :)
@connect2amitu <base href="/">
also didn't work for me.
@Rich0101 solution worked by removing the stylesheet property and adding type="text/html"
in the link tag.
Tks @connect2amitu it works fine
Errors and solutions are weird sometimes.
What worked for me is keep rel="stylesheet"
and additionally add the type="text/css"
also <base href="/">
would not worked for me.
I had this same prob. My folder structure wasn't right. Some how I created my "css" folder inside my "scripts folder". Double check your folder structure. Worked for me.
have the same error and these solutions aren't working
In my case the problem was that webpack-dev-server returns text: "Cannot GET /dist/css/index.css". So check that files exists. Similar problem with js: https://github.com/webpack/webpack/issues/3027
This helped me, https://blog.angularindepth.com/this-is-how-angular-cli-webpack-delivers-your-css-styles-to-the-client-d4adf15c4975
To realise that styles.css becomes styles.js, and therefore it should be included as a script at the bottom of the body rather than at the head as a link.
Checking my file-Url helped me. Errors in your Url input is the main problem. Check whether you have included a static file to connect the view files to the query. Recheck it. It took me 2 hours minimum to find the Error in the Url
Im using MiniCssExtractPlugin and i realized missing '.' will caused below issue.
from
filename: '/style.[contenthash].css'
to
filename: './style.[contenthash].css'
//correct way should be like this
new MiniCssExtractPlugin({
publicPath: './sass/',
filename: './style.[contenthash].css'
});
Hope this help you.
@connect2amitu <base href="/">
solved my issue. Thanks man!
@connect2amitu Thank you :)
adding <base href="/">
before my link tags fixed my issue hope this helps others
Add
<base href="/">
in head before linking all css files
nice trick (y), working like a charm.
Add
<base href="/">
in head before linking all css files
Thanks, it fixed the issue.
ajaa install globally please don't try the easy way... on angular.json in style use: { "input": "your url" } for every javascript you need to add to your project
Add
<base href="/">
in head before linking all css filesnice trick (y), working like a charm.
thans its work for me (gulpjs)
"
The
just updated the sass version of gulp file. "gulp-sass": "3.0.0", then run command gulp sass
Okay! so I changed type="text/css" instead of html. it worked.
Adding
<base href="/">
before linking the stylesheets didn't work for me, but taking the rel property off the<link>
tag did work:<link rel="stylesheet" href="styles.css" type="text/css"> Produces Error <link href="styles.css" type="text/css"> No error
does the job for me
Adding
<base href="/">
before linking the stylesheets didn't work for me, but taking the rel property off the<link>
tag did work:<link rel="stylesheet" href="styles.css" type="text/css"> Produces Error <link href="styles.css" type="text/css"> No error
Perfect! It works!
It's not working for me. I don't know why.
Can you please share the file references ? @hendisantika
i got the following issue after installing froala on my angular app.
it's not applying the style for some reason : any ideas please ?