聘我网

新概念招聘3.0

如何为nginx添加MIME信息?

vote up0vote downstar

想要给csv文件添加text/csvMIME,貌似默认情况是text/plain

我现在是这样做的:

location ~ /static/csv_exports/ {
        add_header Content-Type text/csv;
}

但是返回头部确是:

...
Content-Type: text/plain
...
Content-Type: text/csv
...

也就是Content-Type出现了两次,如何fix该问题?

 

1 个答复

vote up0vote downcheck

add_header指令顾名思义只是累加header

应该使用types指令进行覆盖:

location ~ /static/csv_exports/ {
    types {text/csv csv;}
}
链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.