Resource interpreted as document but transferred with MIME type text/css

前端 未结 2 1639
一向
一向 2020-12-09 14:38

Resource interpreted as document but transferred with MIME type text/css

This is the error that\'s showing up in Google Chrome Inspector.

The

相关标签:
2条回答
  • 2020-12-09 15:24

    I only get error that when I view the specific resource on Chrome. This also happens when I try to open a Javascript file (.js).

    My conclusion is that when you open a component file (.css, .js) in Chrome, it will try to interpret as document (showing output on the screen), instead of interpreting it as its native MIME type.

    Say a Javascript file. If you enter it in Chrome, it should be interpreted as document (showing output on the screen), instead of Chrome executing the script (that's what its native MIME type does).

    That message is Google Chrome only and is negligible, as it only appear when you open a component file.

    0 讨论(0)
  • 2020-12-09 15:25

    I get the same error and I think I know why. If you look at your request headers you see they include:

    Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5

    They especially do NOT include "text/css". So Chrome is telling the server it will NOT accept a response of type "text/css" and when it gets such anyway it reports that happening on its console.

    When I ordinarily include a CSS-stylesheet into an html-page the error-message does not show up because in those cases Chrome request-header says:

    Accept: text/css
    

    But if I try to set

    iframe.src = someCssFile.css
    

    I get the message. So it gives me the clue that I'm trying to load CSS to somewhere where it is not expected. It does load it, but console gives me the message.

    And really it is not an error, it is a Warning, that's what Chrome calls it. A Warning. But I agree it's good to know what's causing it.

    I don't think there's any way to explicitly control the request-headers Chrome sends to the server. Browsers just interpret HTML and based on that come up with the headers they send.

    0 讨论(0)
提交回复
热议问题