Problems encountered in nuxt.js multi-user simultaneous requests

problem description

I"m going to get the token parameters stored in cookie in middleware
No problem was found in the local test,
but after uploading to the official server for a period of time, I found that some users had the same token

.

after checking, it is found that because multiple users have requested the server at the same time, the triggered middleware may have been rewritten (it is not clear how to describe it)

the environmental background of the problems and what methods you have tried

when multiple users request a page at the same time, the value of the context.req.headers.cookie field in
middleware is the same

at first, I thought that the temporary variable saved by myself was repeatedly queried by the server, but the problem was still found after deletion

.

related codes

let getCookie = (cname, cookie) => {
  let name = cname + "=";
  let ca = cookie.split(";");
  let cname_index = cookie.indexOf(name)
  if (cname_index >= 0) {
    for (let i = 0; i < ca.length; iPP) {
      let c = ca[i].trim();
      if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
    }
  } else {
    return null;
  }
}

export default (context) => {
  if (context.route.name) {
    context.marsToken = getCookie("MarsToken", process.server ? (context.req.headers.cookie || "") : (document.cookie || ""));
    context.store.commit("SAVETOKEN", context.marsToken);
  }
}

what result do you expect? What is the error message actually seen?

I would like to ask why this happens because node cannot handle concurrent requests. If so, how can I improve it?
or is it a framework problem?


I have the same problem, especially when using location.href to jump, the Token in store gets mixed up with others, and our business involves switching domain names, so we have to jump. As far as I can see, once locatio.href is used, nuxtServerInit will be initialized again, which may be the result of this problem.
if the domain name is the same, try to use nuxt-link to redirect. If you skip the second-level domain name, it is really impossible to retrieve the token, from the cookie and reset it to the store on the home page of the second-level domain name.


Lou Zhu Da, has this problem been solved? I have also encountered this problem

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf6e0b-3200f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf6e0b-3200f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?