0👍
✅
Your allowed origin is set to port 5173, but you are posting requests using port 8080
Try to replace
@CrossOrigin("http://localhost:5173/")
With
@CrossOrigin("http://localhost:8080")
No need for / after port number since you already have it at
@RequestMapping("/api")
Also your post url in JS has /saveorder/ but you have mapped /saveOrder ‘O’ is lowercase and uppercase respectively
In JS try to replace
http://localhost:8080/api/saveorder/
with
http://localhost:8080/api/saveOrder
-3👍
Try to send header ‘Access-Control-Allow-Origin’: ‘*’ for server method and js function. Also you can use "npm package proxy" for your local application.
Source:stackexchange.com