Home > Back-end >  , the front-end when access to the page how to transmit the Header?
, the front-end when access to the page how to transmit the Header?

Time:11-11

Here is my front login page code, can the backend login authentication account password, and then the backend authentication by will return after a token and jump page, front deposit the token to the localStorage, problem is the time to jump was stopped by the interceptor, jump back to the login page again, heard that can access the page by the Header took token in the past, do you have who know how to take?
<script>
$(function () {
$(" # login "). Click (function () {
Let the params={
"Phone" : $(" input [id='phone'] "). The val (),
"Password" : $(" input [id='password'] "). The val (),
};
$. GetJSON ("/login "params, function (data) {
If (200). The data code==={
LocalStorage. SetItem (' token 'data. The token).
} else {
Alert (data. MSG);
}
Window. The location. Href=https://bbs.csdn.net/topics/data.url;
})
})
})
</script>

Interceptors to judge whether a token code
If (request. GetHeader (" token ")!=null) {
If (loginService. QueryLogin (request. GetHeader (" token "))!=null) {
return true;
}
}

CodePudding user response:

Login method to return the token to the front, the front store, and then visit other interfaces to the authentication token

CodePudding user response:

reference 1st floor ywh22122 response:
login method to return the token to the front, the front store, and then visit other interfaces to the authentication token

I have already returned to the front, the front also receives the saved, now the problem is don't know how to in every link in the Header on the token

CodePudding user response:

It that there is a header information
  • Related