Hi,
I have a CORS problem with my React application.
When i call Keycloak to get a token it works fine, but when i call the same server to do a POST i get a CORS Error :
Access to XMLHttpRequest at ‘http://intssoapp01:8080/auth/realms/web/p-rest-admin-provider/webaccounts’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
I try with XMLHttpRequest and Axios and get the same error. I add Access-Control-Allow-Origin * in the header. There is the code :
const config = {
withCredentials: true,
headers: {
“Content-Type”: “application/json”,
“Access-Control-Allow-Origin”: “*”,
“Access-Control-Allow-Credentials”: “true”,
Authorization: "Bearer " + localStorage.getItem(“token”),
},
};
axios.post(url, { dataPartner }, config).then(res => {
console.log(res);
return res;
});
There is our server configuration
How can i resolve this problem ?
Thank you