If "withCredentials: true", then a 4xx response produces an error of type ERR_NETWORK, not allowing to access the response object
Describe the bug
I figured out that when I'm using "withCredentials: true" I've got a NETWORK_ERROR for a 401 or 403 response, instead of ERR_BAD_REQUEST. But without "withCredentials: true" I've got an error of type ERR_BAD_REQUEST as expected.
To Reproduce
import axios from "axios";
// Create an Axios instance with default options const axiosInstance = axios.create({ baseURL: 'http://an.endpoint.com/api/v1', withCredentials: true, });
axiosInstance.interceptors.response.use( response => response, error => { console.log('Axios response error', error); // <----------- if (error.response.status === 401) { // handle invalid token console.log('Invalid token - requesting new access token'); // request new access token and retry request // note: you can access the original request config with error.config } return Promise.reject(error); } );
export default axiosInstance;
Code snippet
No response
Expected behavior
It should return an error of type ERR_BAD_REQUEST, allowing to access response object
Axios Version
1.6.8
Adapter Version
No response
Browser
Chrome
Browser Version
124.0.6367.119
Node.js Version
No response
OS
No response
Additional Library Versions
React 18.3.1
Additional context/Screenshots
No response
Hi! @jasonsaayman I saw this issue is assigned, but I’d love to help if there’s any related subtask or testing needed. could i start working on this?