对于我的本地开发系统,我正在尝试使用 grunt-contrib-connect 服务前端资产。我需要一个在 Firefox 中使用字体的跨域解决方案。服务器运行得很好,但我似乎无法设置标题。
我正在使用 0.7.1 版的 grunt-contrib-connect。
connect: {
dev: {
options: {
port: '9001',
base: 'build',
hostname: 'localhost',
keepalive: true,
middleware: function(connect, options, middlewares) {
// inject a custom middleware into the array of default middlewares
// this is likely the easiest way for other grunt plugins to
// extend the behavior of grunt-contrib-connect
middlewares.push(function(req, res, next) {
req.setHeader('Access-Control-Allow-Origin', '*');
req.setHeader('Access-Control-Allow-Methods', '*');
return next();
});
return middlewares;
}
}
}
}
将keepalive与中间件一起使用有问题吗?