'Axios request throws 431 error on every request only in google chrome
I am getting 431 in every request-response only in google chrome. Except for google chrome is working fine in all browsers. I debugged a lot but did not find which thing caused it.
Pacakage.json
"dependencies": {
"@babel/core": "7.9.0",
"axios": "^0.26.1",
"react": "^16.13.1",
"react-cookie": "^4.1.1",
}
Here are my Axios configurations, that I'm using as middleware. Every request goes through this.
export default ({ type, method, path, success, isFormData, isBlob, newUrl }) =>
function* (action) {
const {
body,
params,
success: successPayload,
fail: failPayload,
successMessage
} = action.payload || {};
console.log("action.payload", action.payload);
const idToken = localStorage.getItem("idToken") || "";
let header = {};
if (!isFormData) {
header = {
"Content-Type": "application/json"
};
}
header["Access-Control-Allow-Origin"] = "*";
if (idToken !== "") {
header["Authorization"] = `Bearer ${idToken}`;
}
try {
yield put({
type: requestPending(type)
});
let options = {
url: `${typeof path === "function" ? path(action.payload) : path}`,
method: method,
headers: header,
data: body,
params,
};
if (isBlob) {
options.responseType = "blob";
}
let res = yield call(axios.request, options);
} catch (err) {
const errRes = get(err, "response", err);
}
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
