M
M
MifeeX2020-04-28 14:32:44
Node.js
MifeeX, 2020-04-28 14:32:44

Why is node.js updated on different request types?

All the good time of the day. There is a back code for user authorization. "Primary" authorization and with "/auth/me" path. In the primary there is a standard process. Here is the end of the code that writes data to the session

//result - результат сравнения хэшей. 
if (result === true) {
  resultCode = 0;

  req.session.userId = results[key].id;
  req.session.username = results[key].username;

Everything seems to be ok here, the data is saved in the session and everything is cool. However, when trying to connect using "/auth/me", the session is updated. Here is the complete request code
//вместо "userId" и "email" должны быть куки
app.get('/auth/me', (req, res, next) => {
  res.json({resultCode, userId, email})
})


Actually, it's not clear to me what and how and why ... :) I hope someone has ideas. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MifeeX, 2020-04-28
@MifeeX

So, the answer to the question arrived in the form of a property withCredentials: truethat I did not pass in the post (primary) request. Because of this, the cookie was cleaned, and my ass blazed like Vesuvius. Everyone for the future, if you want not to lose your cookie on the go, send it along with the request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question