You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
matricali
changed the title
If "withCredentials: true" the error produced always
If "withCredentials: true", then a 4xx response produces an error of type ERR_NETWORK
May 9, 2024
matricali
changed the title
If "withCredentials: true", then a 4xx response produces an error of type ERR_NETWORK
If "withCredentials: true", then a 4xx response produces an error of type ERR_NETWORK, not allowing to access the response object
May 9, 2024
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
objectAxios 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
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: