node.js - OpenID、Express、React - 通过身份验证将获得的令牌从后端发送到前端
问题描述
在身份验证用户被重定向到/auth/steam/authenticate
存储在 url 中的数据后,这些数据正在使用函数 保存到JWT 令牌steam.authenticate
,之后我试图用令牌将用户重定向到我的前端,但我不知道如何在我的前端处理该请求,因为我我没有从它发送请求。
目标:将用户令牌作为 cookie 保存在我的前端。
app.get("/auth/steam/authenticate", (req, res) => {
try {
steam.authenticate(req.url).then((user) => {
const token = jwt.sign(user._json, process.env.JWT_TOKEN);
return res.redirect("http://localhost:3000/"); //Frontend
});
} catch (error) {
console.error(error);
}
});
解决方案
推荐阅读
- bash - 使用 bash 从网站中抓取特定的超链接
- sql - 我希望有人检查我的代码并确定语法错误
- c# - 以功能方式将整数列表聚合或连接成字符串
- python - 获取边界内最近邻居列表
- android - Flutter Listview 在从视频 url 加载缩略图时冻结,我的应用程序崩溃了
- r - joining two dataframes between dates together
- react-native - Stacknavigatior 导航到已经在堆栈中的屏幕
- php - 在 Laravel 中提交 POST 表单后出现 302 错误
- xamarin - Azure OCR 识别PrintedTextInStreamAsync 无效图像
- java - 尝试在我的适配器类中的空对象引用上调用虚拟方法“void android.widget.TextView.setText(java.lang.CharSequence)”