I have read some articles. There are generally two ways to deal with token expiration by separating items in front and back end, namely, re-login after expiration and refreshing token renewal.
1. Log in again after token expires;
Operation points
1. After the frontend login obtains the token, the frontend will carry token;
2. Each time the frontend carries the token to initiate the request, the backend updates the validity period of the token to the maximum.
3. If the token expires because it is not used for a long time, the backend will return the specified status code when the frontend requests, and the frontend will jump to the login page according to the status code.
II. Refresh the token for renewal at the backend without logging in again:
the operation procedure of the second method is the problem. Describe it in detail:
1. Does the backend judge that the token expires as a prediction? Or will it be refreshed until it expires, and there is no need for pre-judgment at all?
2. When the backend refreshes the token, how do you tell the frontend to update the token?
maybe the question is not to the point. Please tell me the specific steps of token renewal. (the front end uses vue-cli, to send requests using axios,. It would be better if there is some sample code. )
Thank you, boss.
