When vue jumps from the link to the home page, it gets the token from url and adds it to the request header.

Today, I encountered a problem when someone clicked on my project link in other projects and redirected to my home page. I got the token of url on the home page and stored it in vuex. I sent a request after performing this operation, but the request header of the home page did not add token. I jumped to other pages and found that there was, and then jumped back to the home page. Header added it, but every time I opened the item for the first time. Purpose: the request on the home page can"t be added to token. I"ve tried all kinds of methods. Can you help me to see how to solve it?

clipboard.png

clipboard.png

Nov.19,2021

as I said upstairs, I think so. Make a loading page, put a loading image, and only do an operation to get token and put it in header. After success, jump to your home page. If it is fast enough, it may be finished in 1 second, giving users a feeling of loading when jumping, which should have no effect.


try to remove the promise from getuserToken

getUserToken({}){
    commit(...)
}

set a blank page, get the token and set it, and then skip to the home page

Menu