i'm using jwt token login in spring. when login success, server send redirect response include access-token at response header. so, i want catch the response at front-side, set the token at request header and send fetch request to response header 'location'.
but, fetch cannot catch the redirect response. fetch automatically try to redirect and catch after all redirect ends(200 status code).
this is my front code.
function sub(url, form) {
var option = {
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'id=' + form.id.value + "&password=" + form.password.value
}
fetch(url, option)
.then(response => { // here that i want to catch redirect response. but status is 200
if (response.status === 302) {
fetch(response.headers.get('location'), {
headers: {
Authentication: response.headers.get('Authentication')
}
})
}
})
}
please tell me how can i catch redirect response before redirect..
this is my browser network tab.