froala / angular-froala

Angular.js bindings for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
MIT License
306 stars 123 forks source link

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

Closed maathi closed 6 years ago

maathi commented 6 years ago

i got the following issue after installing froala on my angular app. froala

it's not applying the style for some reason : froalastyle any ideas please ?

stefanneculai commented 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.

craigpearson commented 6 years ago

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

Jeeva-Rathinam commented 6 years ago

@mehdi-desu did you solve your issue?

3amroSalem commented 6 years ago

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.

connect2amitu commented 6 years ago

image Add <base href="/"> in head before linking all css files

Jeeva-Rathinam commented 6 years ago

Did you solve the issue?

3amroSalem commented 6 years ago

in my case I already had in my index for some reason the issue is gone when I used --aot to compile my project.

dharmmaurya563 commented 6 years ago

The issue is not resolved http://prntscr.com/jecsmv

hgsigner commented 6 years ago

@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.

vanoMekantsishvili commented 6 years ago

@connect2amitu this trick actually works for me too but can you explain how this thing works? thank you : )

DaoFof commented 6 years ago

@connect2amitu it doesn't work for me

claudialphonse78 commented 6 years ago

@connect2amitu this trick worked ,thanks a lot!

frempongandrews commented 6 years ago

<base href="/"> Worked for me, thanks!!

krasicji commented 6 years ago

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

atinyakov commented 6 years ago

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

sudiptosen commented 6 years ago

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!

arduino731 commented 6 years ago

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!

Youssef-Ait-Elhaj commented 6 years ago

Having the same issue currently.

iamsuyogbankar commented 6 years ago

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">
iamsuyogbankar commented 6 years ago

i have saved photo in c folder.how to give path?

TheSLX commented 6 years ago

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.

Rich0101 commented 6 years ago

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
ovidiup13 commented 6 years ago

@Rich0101 The error disappears but the styles are not applied unfortunately :confused:

Piligrim25 commented 6 years ago

Just add type="text/html" Like this

keeve commented 6 years ago

@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 :)

arshad115 commented 6 years ago

@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.

ulrichdohou commented 6 years ago

Tks @connect2amitu it works fine

pathum-kalhan commented 6 years ago

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.

gladtobhere commented 6 years ago

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.

pshoultz commented 6 years ago

have the same error and these solutions aren't working

piliugin commented 6 years ago

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

raulra08 commented 6 years ago

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.

wisedip commented 6 years ago

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

ming0627 commented 6 years ago

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.

AvinashMV commented 6 years ago

@connect2amitu <base href="/"> solved my issue. Thanks man!

Avi308 commented 6 years ago

@connect2amitu Thank you :)

akshaymittal143 commented 6 years ago

worked for me as well. Thanks

shahramverb commented 6 years ago

image

adding <base href="/"> before my link tags fixed my issue hope this helps others

ujikit commented 6 years ago

image Add <base href="/"> in head before linking all css files

nice trick (y), working like a charm.

ranakhurram666 commented 6 years ago

image Add <base href="/"> in head before linking all css files

Thanks, it fixed the issue.

errepy commented 6 years ago

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

ghost commented 6 years ago

image Add <base href="/"> in head before linking all css files

nice trick (y), working like a charm.

thans its work for me (gulpjs)

yeasin-Ahammed-apon commented 5 years ago

"" is working fine for me . thank you.

yonatanLehman commented 5 years ago

The didn't work for me. My problem was that the path to the file was in mixed lower and uppercase and the actual folder structure was in lowercase. My local machine is windows and the actual site is on a Heroku server which seems to be Linux. Also renaming my local folder to match the case of the link didn't to work, since in Git renaming a folder (and I suppose file) does not get passed on. I had to copy the folder aside, delete the original folder, git commit, git push, and then recreate the folder and commit and push again.

vishaldocuments1995 commented 5 years ago

just updated the sass version of gulp file. "gulp-sass": "3.0.0", then run command gulp sass

krishnavaddepally commented 5 years ago

Okay! so I changed type="text/css" instead of html. it worked.

bhagirath-patadia commented 5 years ago

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

vigneshikl commented 5 years ago

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!

hendisantika commented 5 years ago

It's not working for me. I don't know why.

Screen Shot 2019-04-12 at 08 18 09
vigneshikl commented 5 years ago

Can you please share the file references ? @hendisantika