Search code examples
javascripthtmlcssnode-red

Node-Red: Connecting an External CSS File to HTML Nodes


If there is any documentation on this topic on the Node-Red website, please let me know.

I am building a static website (HTML/JS/CSS) with Node-Red. I use HTTP GET nodes to call my Javascript and CSS files. I connect my Javascript through the tag, and this works well. I can connect my CSS file through the . When I visit that css_http response (which is linked to my Node-Red server), I can see the CSS file. However, all of my HTML files are ignoring the CSS files.

On the console, I get a "CSS was ignored due to mime type mismatch" warning, but I can access the CSS file through HTTP, and I double-checked to make sure my syntax was correct.

I currently load a single CSS file through the payload, and this works, but the code still looks messy in the console.

Is there any way I can link my external CSS file through a Node without using the payload (using the tag would be ideal)? Should I have my external CSS file in an HTML outside of the server? Why does it work for my JavaScript files but not my CSS ones?


Solution

  • As the error points out you are sending a CSS file with the wrong mime type.

    "CSS was ignored due to mime type mismatch"

    You can set the mime type with the "Content-Type" header in the http-response node.

    enter image description here