I am receiving "Web browser data loading may be possible, due to a Cross Origin Resource Sharing (CORS) misconfiguration on the web server" when running a program. Below is the code snippet where I am speculating the error is occuring, but I am having hard time finding what is wrong. I have checked Access-Control-Allow-Origin header already also. Could this be a potential false postiive?
@RestController
public class CommentController {
private static final String template = "%s commented: %s!";
private final AtomicLong counter = new AtomicLong();
@CrossOrigin(origins = "example.com")
@GetMapping("/comments")
public Comment comment(@RequestParam(required = false, defaultValue = "World") String commentId, String email) {
User user = UserRepository.findByEmailAddress(email);
Comment comment = CommentRepository.findByUserAndCommentId(user, commentId);
return new Greeting(counter.incrementAndGet(), String.format(template, user.toString(), comment.toString()));
}
}
``
Aucun commentaire:
Enregistrer un commentaire