Some questions about the separation of front and rear ends

after logging in for the first time, save the token locally, and then every time you jump to a new page, you have to send a request to the server to verify whether the token is legal, display the page if it is legal, and force you to jump back to the login page if it is illegal?

Jun.15,2022

No additional requests are required, just send them in the header that is placed in the normal business request.


Verification token can determine whether the login has expired


you can refer to the solution of JWT


. The back end mainly provides data, and the front end provides data display and rendering. So before each time you get the data, you should attach the login token to the request header to verify it, and return the correct data if the login information is legal. Then the front-end rendering. If the login information is wrong, the relevant error message is returned, and the front end displays the relevant page according to the error message, such as displaying the login page.

Menu