为什么express-js不设置Content-Type头? [英] Why isn't express-js setting the Content-Type header?
本文介绍了为什么express-js不设置Content-Type头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下内容:
var express = require('express'),
app = express.createServer();
app.get("/offline.manifest", function(req, res){
res.contentType("text/cache-manifest");
res.end("CACHE MANIFEST");
});
app.listen(8561);
Chrome中的网络标签表示 text / plain
。为什么不设置标题?
The network tab in Chrome says it's text/plain
. Why isn't it setting the header?
上面的代码正常工作,我的问题是由链接到旧版本的express-js引起的>
The code above works, my problems were caused by a linking to an old version of express-js
推荐答案
res.type('json')
这篇关于为什么express-js不设置Content-Type头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文