CORS iSSUES
This commit is contained in:
@@ -1445,6 +1445,67 @@ class usersService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
postAuxEnd(uri, reqData) {
|
postAuxEnd(uri, reqData) {
|
||||||
|
const endPoint = process.env.REACT_APP_USERS_ENDPOINT + uri;
|
||||||
|
const session_token = localStorage.getItem("session_token");
|
||||||
|
// session_token = session_token !=null ?session_token : '';
|
||||||
|
// 'Authorization': `Basic ${(session_token !=null) ?session_token : ''}`,
|
||||||
|
let axiosConfig = {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Expose-Headers": "Access-Control-Allow-Origin",
|
||||||
|
"Access-Control-Allow-Headers":
|
||||||
|
"Origin, X-API-KEY, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Access-Control-Allow-Headers, Authorization, observe, enctype, Content-Length, X-Csrf-Token",
|
||||||
|
"Content-Type": "application/json;charset=UTF-8",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
// Axios.defaults.headers.post['Content-Type'] ='application/json;charset=utf-8';
|
||||||
|
// Axios.defaults.headers.post['Access-Control-Allow-Origin'] = '*'; //,axiosConfig
|
||||||
|
// Axios.defaults.withCredentials = true;
|
||||||
|
//debugger;
|
||||||
|
return Axios.post(endPoint, reqData)
|
||||||
|
.then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
console.log("~~~~~~~ WrenchBoard::POST ~~~~~~~~");
|
||||||
|
if (response.data.internal_return == "-9999") {
|
||||||
|
localStorage.clear();
|
||||||
|
window.location.href = `/login?sessionExpired=true`;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (error.response) {
|
||||||
|
//response status is an error code
|
||||||
|
console.log(
|
||||||
|
"ERROR-------------------------------------------------------"
|
||||||
|
);
|
||||||
|
console.log(error.response.status);
|
||||||
|
console.log(
|
||||||
|
"ERROR-------------------------------------------------------"
|
||||||
|
);
|
||||||
|
} else if (error.request) {
|
||||||
|
//response not received though the request was sent
|
||||||
|
console.log(
|
||||||
|
"ERROR2-------------------------------------------------------"
|
||||||
|
);
|
||||||
|
console.log(error?.request);
|
||||||
|
console.log(
|
||||||
|
"ERROR2-------------------------------------------------------"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
//an error occurred when setting up the request
|
||||||
|
console.log(
|
||||||
|
"ERROR3-------------------------------------------------------"
|
||||||
|
);
|
||||||
|
console.log(error);
|
||||||
|
console.log(
|
||||||
|
"ERROR3-------------------------------------------------------"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
postAuxEnd_BROKE(uri, reqData) {
|
||||||
const endPoint = process.env.REACT_APP_USERS_ENDPOINT + uri;
|
const endPoint = process.env.REACT_APP_USERS_ENDPOINT + uri;
|
||||||
const endPointKey = process.env.REACT_APP_ENDPOINT_KEY;
|
const endPointKey = process.env.REACT_APP_ENDPOINT_KEY;
|
||||||
const session_token = localStorage.getItem("session_token");
|
const session_token = localStorage.getItem("session_token");
|
||||||
|
|||||||
Reference in New Issue
Block a user