I was running own website on localhost, with the server showing everything correct, Chrome gives me some errors:
Refused to apply style from 'http://example.com' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Is there any way to skip it or disable it?
You don't have to disable MIME checking. See an explanation.
The problem is probably, that your stylesheet file is not accessible with the URL you defined in the link element. Maybe just a typing error. Try to click on the link in the error message and see if it can be loaded.
Check your stylesheet references in your code
<link rel="stylesheet" type="text/css" href="/styles/styles.css" />
Related
I have read numerous questions with a similar trouble but they usually were caused by a server misconfiguration. I use unpkg.com service so I assume it is configured correctly.
My HTML5 static page contains:
<link rel="stylesheet" type="text/css" href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/bootstrap-vue#latest/dist/bootstrap-vue.css">
My app is written in Vue but that code is still present in generated file.
Chrome shows the following warnings:
Resource interpreted as Stylesheet but transferred with MIME type text/plain: "https://unpkg.com/bootstrap/dist/css/bootstrap.min.css".
Here is the response caught by Network tab in Developer tools. Content type is text/plain
And the second redirected request with text/css:
When I enter this URL in Chrome location bar, I receive 302 status code first having the text/plain mime type first and the second fetch is expected text/css.
Is this sort of Chrome bug that it complains about the content type of request to be redirected? Or is it unpkg.com error? Is there a way to get rid off these errors (I can bundle the file in my Vue app but I want to minimize the transfers).
You can try it live here: https://beta.mezinamiridici.cz/ankety/jizda-v-tesnem-zavesu-za-kamionem
I'm building a personal website, and I got an error in chrome that reads:
"Refused to apply style from 'http://localhost:3000/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."
But everything seems to be linked just fine. I'm using Express, EJS, and Bootrap. I have this line in my Express:
app.use(express.static(__dirname + "/public/"));
And I linked my style sheelt like normal:
link rel="stylesheet" href="styles.css" type="text/css"
I don't know what could be causing this issue. I don't have anything inside of the actual css file, and it is in the main directory with everything else.
I think the css file is not found on your server so when your server searches for the css file and it doesn't finds it.It returns back with html MIME type.
You can also import your css file in App.js component
import './css/styles.css';
Or Just change 'href' to 'src'.
<link rel="stylesheet" href="./css/styles.css">
to this:
<link rel="stylesheet" src="./css/styles.css">
Why won't my HTML image load? It just shows a blue box that represents an image?
Here is my directory structure
And here is my code
<body>
<img src="ImageFolder/download.jpg">
<h1> Welcome to my smelly fish</h1>
</body>
Here are the errors from chrome
Refused to apply style from
'http://localhost:3000/css/main.css' because its MIME
type ('text/html') is not a supported stylesheet MIME
type, and strict MIME checking is enabled.
download.jpg:1 Failed to load resource: the server
responded with a status of 404 (Not Found)
localhost/:1 Refused to apply style from '
http://localhost:3000/css/main.css' because its MIME t
ype ('text/html') is not a supported stylesheet MIME
type, and strict MIME checking is enabled.
I have a website running perfectly fine on Chrome, Firefox, Safari etc. however, the CSS does not load in Internet explorer (any version) as well as in MS Edge browser.
The Console shows this infamous error related to MIME Type:
SEC7113: CSS was ignored due to mime type mismatch
File: application-2015-2a0565839ee60a029c49fc918e3625e9.css
SEC7113: CSS was ignored due to mime type mismatch
File: CustomCss.css
SEC7113: CSS was ignored due to mime type mismatch
File: print.css
I have checked in the code, and this is how it is in the <head>
// ASP.NET MVC code - .cshtml layout file
<link href='#Url.Content("/Content/application-2015-2a0565839ee60a029c49fc918e3625e9.css")' media="screen" rel="stylesheet" type="text/css"/>
<link href='#Url.Content("/Content/CustomCss.css")' media="screen" rel="stylesheet" type="text/css"/>
<link href='#Url.Content("/Content/2015/print.css")' media="print" rel="stylesheet" type="text/css"/>
I have checked in the IE Developer Tools, and the css indeed returned with incorrect MIME type (coming as blank) in IE instead of stylesheet or text/css as in Chrome or Firefox:
IE:
Chrome:
I have checked in IIS, the mime type for .css is mapped as expected:
How can I make IE to understand the Mime type and let it load it correctly.
Any help is highly appreciated.
EDIT
As suggested, also checked the Registry value for .css in HKEY_CLASSES_ROOT and this seems ok as below:
Also, ensured that no program is associated with CSS to open.
This is because under default settings, “static content” is not installed with IIS.
To enable this on a Windows Server 2008 machine do the following
Fire up Server Manager
Select Web Server under Roles – notice that Static Content is not installed
Select Add Role Services from the right hand menu
Check Static content and install
i think it works for you
It turns out that there was an HTTP Module which was the root cause of it as it turns out to be a known issue with ASP.NET, IIS and HTTP Module aas mentioned here:
ASP.NET CSS file not loaded when adding HttpModule to web.config
Following this and handling in Http Module explicitly for css, fixed this issue.
Thanks for everyone for taking time out and providing your expert comments
Looks like you've tried everything that seems to have worked for others.
Try setting the output to the mime type through the ASP.NET framework:
Response.ContentType = "text/css";
Have you tested using a load function?
Response.ContentType = "text/css"
Response.AddHeader("Header")
Response.WriteFile("CSS File.css")
Response.End()
Response.Clear()
You should check these things because if IE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
or
type="text/css" instead of type="css/stylesheet" when importing the stylesheet.
The Error I get on my website in IE console is
SEC7113: CSS was ignored due to mime type mismatch
Seems the CSS is not getting loaded at all.
I have researched a lot.There are quite a few questions on this around the web, but there is no conclusive fix.
Microsoft official site says to add type="text/css" attribute to the link tag, but in my case, I have already added it, in vain.
Is there any fix to this?
You need to set the Content-Type http header to text/css. With htaccess:
AddType text/css css