更新时间:2023-12-03 21:10:04
这是我写的一个小片段.你可以作为一个例子来了解如何访问meteor 的核心连接和修改头文件,这也是每个meteor 项目的一个很好的插件:
Here is a little snippet I wrote. You can use as an example in how to access meteor's core connect and modify headers, also a pretty good drop-in for every meteor project:
/**
* HTTP Header Security
*
* enforce HTTP Strict Transport Security (HSTS) to prevent ManInTheMiddle-attacks
* on supported browsers (all but IE)
* > http://www.html5rocks.com/en/tutorials/security/transport-layer-security
*
* @header Strict-Transport-Security: max-age=2592000; includeSubDomains
*/
var connectHandler = WebApp.connectHandlers; // get meteor-core's connect-implementation
// attach connect-style middleware for response header injection
Meteor.startup(function () {
connectHandler.use(function (req, res, next) {
res.setHeader('Strict-Transport-Security', 'max-age=2592000; includeSubDomains'); // 2592000s / 30 days
return next();
})
})