Answer the question
In order to leave comments, you need to log in
Why isn't the Set-Cookie header coming?
There are two applications: client and server. Both lie on different domains (in my case - on different ports).
The client (JavaScript application), using axios, makes the following request:
axios.get(API.getUserData(), {withCredentials: true}).then(response => {
if (response.status === 200) {
console.log('Получены данные пользователя: ' + response.data);
}
}).catch(exception => {
console.log('Ошибка доступа к серверу');
console.log('Детали ошибки: ' + exception.toString());
});
//начало метода
response.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "http://localhost:2323"); //Адрес клиента
response.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
response.addHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET");
response.addHeader(HttpHeaders.SET_COOKIE, "token=" + getStringToken());
response.setStatus(200);
//установка тела ответа и возврат результата
Answer the question
In order to leave comments, you need to log in
Access-Control-Allow-Headers: ...Set-Cookie...
Where do you have it?
It comes, but it cannot be accessed from JS, because the Set-Cookie header is on the blocked list.
https://developer.mozilla.org/en-US/docs/Web/API/H...
https://developer.mozilla.org/en-US/docs/Glossary/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question