I'm trying to make a request from my reactjs client side (running on webpack server) to my testing backend in java.
both are localhosted but on different ports (3000 and 8888).
When i am using postman to request to my backend i get the expected response, so all seems to going right.
However, when i want to request from react, i have this error related to CORS :
XMLHttpRequest cannot load http://localhost:8888/api. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
I think my backend server doesn't allow http request from my react server. So i need to find a way to let my backend know that it's okay to for handle request from react.
There is my test backend. Like i said before my backend is used as an API not as a servlet.
public class test {
public Name getName() {
Name name = new Name("John");
return name;
}
}
Any solution ?