[Vuejs]-Has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. vue to spring

0👍

One quick solution is to tell the controller method to enable CORS via CrossOrigin annotation on the method. So in your case just edit the controller method to this:

@GetMapping("/getNoticeList")
@CrossOrigin(origins = "http://localhost:3000")
public String getNoticeList() {
  return "asdsad";
}

Assuming that you run your frontend app on port 3000.

Leave a comment