Axios won't send cookie, Ajax (xhrFields) does just fine
I was facing a similar issue. Making a get/post request through Axios did not sent the same headers as a straight XHR request.
Then I just added the following just after the Axios require statement:
axios.defaults.withCredentials = true;
After that Axios started sending my cookie like the regular XHR request did.
Working example using Danielo515's answer:
import * as axios from 'axios';axios.defaults.withCredentials = true;export function getAll() { const url = 'https://example.com'; return axios.get(url);}