Thank you for the support. This issue has been solved.
Actually, I read an article on Medium that told me about the way to resolve CORS errors in the Spring application by allowing headers, origins, and many other things. That resolved the issue, and login registration functionality was working fine.
But when I implemented the Cart Page, which is a secured route and requires an authentication token to be sent with the request, then the authorization token was not reaching the Spring application.
So, I read the documentation of Spring and looked for many solutions on YouTube. After some time, I found a video on YouTube.
Youtube LInk: https://youtu.be/uMJnAxapF7E?si=u5myiwDTOIVmpxqk
So what I did, I Still configured the Cors setting but this time, I configuired WebMvcConfigure as FOllows:
@Configuration
public class WebConfig {
@Bean
public WebMvcConfigurer corsConfig() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:5173")
.allowedMethods(HttpMethod.GET.name(),
HttpMethod.POST.name(),
HttpMethod.DELETE.name(),
HttpMethod.PUT.name())
.allowedHeaders(HttpHeaders.CONTENT_TYPE,
HttpHeaders.AUTHORIZATION);
}
};
}
}
One more thing: