我有一个 node 应用程序作为 web 应用程序框架运行 express,我使用 Stormpath 进行身份验证。
Storm path 提供了使用多个中间件保护路由的能力,例如:
router.get('/user_data_api', stormpath.apiAuthenticationRequired, function(req, res) {
res.send('hello you are authenticated!");
});
});
我想要做的是将 authenticationRequired 作为中间件添加到 express 的静态定义中:
app.use(express.static(__dirname + '/public'));
这可以通过向静态资产添加路由来实现,所以如果我有一个文件 ./public/index.html 我可以像这样设置路由:
app.use('/secured-assets',
stormpath.auth_fn, express.static(__dirname + '/public'));
但随后文件将在
www.mydomain.com/secured-assets/index.html
我想要它
www.mydomain.com/index.html
帮助?