OpenID, Express, React - sending obtained token by authentication from backend to frontend

Viewed 62

after authentication user gets redirected to /auth/steam/authenticate with data stored in url which are being saved to JWT Token using function steam.authenticate, after this I am trying to redirect user to my frontend with token but I don't know how to handle that request in my frontend since I am not sending request from it.

GOAL: Save user token in my frontend as a 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);
  }
});
0 Answers
Related