OpenID、Express、React - 将通过身份验证获得的令牌从后端发送到前端

问题描述

在身份验证用户重定向/auth/steam/authenticate 后,使用函数 steam.authenticate 将存储在 url 中的数据保存到 JWT 令牌,之后我尝试将用户重定向到我的前端带有 令牌,但我不知道如何在我的前端处理该请求,因为我没有从它发送请求。

目标:在我的前端将用户令牌保存为 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);
  }
});

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)