I having blocked by CORS on the client side, so I added these configuration on spring boot to allow api calls on my react app:
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("http://localhost:3000");
}
}
Then this is my api call on my React app:
const res = await axios({
method: "POST",
url: "http://localhost:8080/login",
headers: {
"Access-Control-Allow-Origin": "*",
"content-type": "application/x-www-form-urlencoded",
},
data: {
username,
password,
},
});
However I'm still getting blocked by CORS error
