跨域访问前端报错No ‘Access-Control-Allow-Origin‘ header is present on the requested

跨域访问前端报错No ‘Access-Control-Allow-Origin‘ header is present on the requested,第1张

跨域访问前端报错No ‘Access-Control-Allow-Origin‘ header is present on the requested

现在我们很多的项目都是前后端分离的方式

场景就好像这样

我们在localhost:8888端口开发前端项目

localhost:9999端口开发后端项目

这样我们通过8888端口访问9999端口的数据称为跨域请求通常会报错

我们需要在后端项目的控制层加上一些注解(springboot开发后端的)

@CrossOrigin

就是在我们写接口的类上添加注解

这样跨域请求的问题就可以解决了

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5718004.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存