前言
部署項(xiàng)目到nginx
環(huán)境的時(shí)候遇到一個(gè)問(wèn)題:nginx
文件響應(yīng)類(lèi)型不對(duì)導(dǎo)致瀏覽器css
解析失敗膝昆,這篇文章做一個(gè)記錄仙粱。
原因
- 因?yàn)?code>nginx默認(rèn)返回的
mime
類(lèi)型是application/octet-stream
配置nginx
在nginx
的配置里面引入mine.types
文件术徊。
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
root html;
index index.html index.htm;
}
}