-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refused to apply style from <URL> because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled angular #170
Comments
@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 |
Did you solve the issue? |
in my case I already had in my index for some reason the issue is gone when I used --aot to compile my project. |
The issue is not resolved |
@connect2amitu you saved my day here :) I was having this problem with react and react router running with webpack-dev-server and |
@connect2amitu this trick actually works for me too but can you explain how this thing works? thank you : ) |
@connect2amitu it doesn't work for me |
@connect2amitu this trick worked ,thanks a lot! |
|
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 |
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
I get the same error when the |
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 |
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?
|
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. |
Adding
|
@Rich0101 The error disappears but the styles are not applied unfortunately 😕 |
Just add type="text/html" |
@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. .body-container .mat-button { It works :) |
@connect2amitu |
Tks @connect2amitu it works fine |
Errors and solutions are weird sometimes. |
All pages of my blog site was loading the CSS correctly, except for the blog-post page, which I was populating using the Adding base href="/" below the <title> tag before the tags got it working in the header.ejs file solved the issue. |
@ovidiup13 is your problem solved I have same problem. |
I works but unfortunately css is not applied |
same problem with ElectronJs and AngularJs if url has a param like:
After page reload To save the situation I change URL params yo queryParams: From To
|
i am doing the project from wsl in windows |
it needs to mount the folder where the css files are ... |
adding this line of code to my nginx server solved my problem
|
none of this ones worked for me please if you have the solution please share with me |
Could you please explain the purpose of the |
if you are using django, you may forget to install whitenoise when debug turn off.
then append this into middleware variables in the settings file
|
Thanks a lot. That did the trick for me. Bless you. |
if you are using django, you may forget to install whitenoise when debug turn off. pip install whitenoise then append this into middleware variables in the settings file "whitenoise.middleware.WhiteNoiseMiddleware", YOUR MY LIFE SAVER THANK YOU VERY VERY MUCH.. |
|
Just create a 'public' directory and place all your static files and folders inside it. |
Hi @connect2amitu I have tried your solution but still not resolved can you tell me any another solution? |
So if anyone is still struggling what worked for me was the following: my links were written like ../web-shop/css-sytle/style.css and the server would not for the life of me find these links. They worked fine directly from the HTML file. What I had to do is write it /web-shop/css-style/style.css. And that worked like a charm. Man I lost 5 days on this. |
change style.css to index.css. it will solve. |
i got the following issue after installing froala on my angular app.
it's not applying the style for some reason :
any ideas please ?
The text was updated successfully, but these errors were encountered: