搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

The stylesheet was not loaded because its MIME type, “text/html”, is not “text/css”.

  • 1 回覆
  • 0 有這個問題
  • 4 次檢視
  • 最近回覆由 nairb1958

more options

I am sorry if this is not the place to ask this question. I am new to web development and have been trying to solve this issue for days. I have an ESP32 acting as an http server. I have developed web pages which have separate html, css, and javascript files. These work as expected when delivered locally (i.e. I double click on the the files), however, when they are served by the ESP the style sheet is ignored and I get the message

The stylesheet (url) was not loaded because its MIME type, “text/html”, is not “text/css”.

from Firefox debugger. The stylesheet is ignore across all browsers (Firefox, Chrome, Opera, Edge), however the error is only shown in Firefox. Normally, of course, I would expect an issue on the ESP32 side, however, the non-Firefox browsers do load the stylesheet (even tough they ignore it) and I am able to verify that the stylesheet is identical to the one served locally.

Oddly, if I open a Firefox tab and load the page, switching to developer mode causes several requests for the stylesheet and the styles are then applied. Subsequent refreshes of the page causes the style to be lost and closing/opening developer mode has no effect.

Although I have disabled javascript to try fix this problem, when javascript is loaded I get a similar message (except the javascript is loaded).

I believe I specified the MIME type because I exactly coped several examples

<meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="styles.css"> <title>My ESP32</title> Thanks for the help!

I am sorry if this is not the place to ask this question. I am new to web development and have been trying to solve this issue for days. I have an ESP32 acting as an http server. I have developed web pages which have separate html, css, and javascript files. These work as expected when delivered locally (i.e. I double click on the the files), however, when they are served by the ESP the style sheet is ignored and I get the message The stylesheet (url) was not loaded because its MIME type, “text/html”, is not “text/css”. from Firefox debugger. The stylesheet is ignore across all browsers (Firefox, Chrome, Opera, Edge), however the error is only shown in Firefox. Normally, of course, I would expect an issue on the ESP32 side, however, the non-Firefox browsers do load the stylesheet (even tough they ignore it) and I am able to verify that the stylesheet is identical to the one served locally. Oddly, if I open a Firefox tab and load the page, switching to developer mode causes several requests for the stylesheet and the styles are then applied. Subsequent refreshes of the page causes the style to be lost and closing/opening developer mode has no effect. Although I have disabled javascript to try fix this problem, when javascript is loaded I get a similar message (except the javascript is loaded). I believe I specified the MIME type because I exactly coped several examples <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="styles.css" /> <!--<link rel="stylesheet" type="text/css" href="name-of-stylesheet.css" /> --> <!-- <script type="text/javascript" src="ESP-UI.js"></script> --> <title>My ESP32</title> </head> Thanks for the help!

所有回覆 (1)

more options

I can't figure out how to edit my message, but for anybody else it turns out you have to explicitly describe the type of file via httpd_resp_set_type(req, resp_type )

So, for css resp_type has to be "text/css"

有幫助嗎?

問個問題

如果您還沒有帳號,您必須先登入帳號 來回覆文章。還沒有帳號的話,只能發問新問題