tactic
tactic

Reputation: 57

Using NGINX, css files not working

The css files are loading but the issue is that they're not applying, but here's the strange part. If I edit it in chrome in any way (typing a character and deleting it), the style sheet applies. I'm fairly certain the issue is with nginx because when I run a local server (node.js http-server), the css file works.

I added this to my config to make sure it was sending and being interpreted as the right type of file but it still doesn't work.

location ~ \.css {
  add_header Content-Type text/css;
}

This is the website if anyone wants to look at it or try editing the css file.

Upvotes: 2

Views: 11673

Answers (1)

Stephan Köninger
Stephan Köninger

Reputation: 314

If you have a look at the headers sent to the browser, one receives two content-types now which is wrong. The browser interpretes the CSS as plain/text and hence cannot apply the css.

Content-Type:text/plain
Content-Type:text/css

What does your nginx config look like? Do you include /etc/nginx/mime.types; anywhere alike here: https://www.nginx.com/resources/wiki/start/topics/examples/full/

Upvotes: 7

Related Questions