var claims = [];
app.get('/', ensureAuthenticated, function(req, res) {
claims = req.user['_json'];
app.use(express.static(path.join(__dirname, '/client/build')));
res.sendFile(path.join(__dirname, '/client/build/index.html'));
});
上述路由和中间件对尝试登录我的应用程序的用户进行身份验证,我希望将登录的用户详细信息与 res.sendFile 一起发送到 UI,并在我的 angular2 .ts 文件中访问它们。我怎样才能这样做?
声明具有登录的用户详细信息
最佳答案
使用 Express,您无法同时发送文件和数据。您将需要创建两个单独的路由来获取您的用户详细信息和网页。
有关更多详细信息,请参阅此答案:https://stackoverflow.com/a/31461737/4719679
关于node.js - 如何在提供静态内容时使用 res.sendFile() 发送参数并在 UI Controller 中访问它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48906393/