我正在尝试使用grunt-contrib-connect在我的本地开发系统上提供前端资源。我需要在Firefox中使用字体的跨域解决方案。服务器可以正常运行,但似乎无法设置头文件。
我正在使用grunt-contrib-connect的0.7.1版本。
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会有问题吗?