后端解决前后端分离跨域问题:Access to XMLHttpRequest at 'http://127.0.0.1:1203/stu/addStu' from origin 'http://localhost:8081'
JS访问后端接口时,出现跨域问题:
Access to XMLHttpRequest at 'http://127.0.0.1:1203/stu/addStu' from origin 'http://localhost:8081' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
解决:
后端Controller添加@CrossOrigin注解即可
参考: