Ok, I figured out a solution for my problem but I would like to know if anyone can help me understand why this happened.
My app.js has:
app.use(express.static(__dirname + '/public'));
and static files are served as expected.
Except, when I tried to add a background image in my css:
html {
background: url(img/tree.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
I had the error:
Resource interpreted as Image but transferred with MIME type text/html: "http://localhost:3000/css/img/tree.jpg". localhost/:1
Now when I change the CSS to /img/tree.jpg
The file is served correctly -- so here is a question -- there shouldn't be any file at /css/img/tree.jpg so why does the server think an image is sent with text headers instead of just returning resource not found?
Thank you for your help!