700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 解决No Access-Control-Allow-Origin header is present on the requested跨域问题

解决No Access-Control-Allow-Origin header is present on the requested跨域问题

时间:2023-06-28 09:11:18

相关推荐

解决No Access-Control-Allow-Origin header is present on the requested跨域问题

今天在学习vue的时候,简单的做了一个前后端分离的测试,

通过axios请求本地项目的内容时报错:

Failed to load http://localhost:8082/XXXX: No 'Access-Control-Allow-Origin' header is present on the requestedresource. Origin 'http://localhost:8082' is therefore not allowed access.If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

直接翻译:

加载失败http://localhost/本地主机:8082/XXXX号:

请求的上不存在“Access Control Allow Origin”头

资源。起源’http://localhost/本地主机:8082’因此不允许访问。

如果不透明的响应满足您的需要,请将请求的模式设置为“否”-

cors’来获取禁用cors的资源。

可能是因为两个原因引起,一个是响应头,一个是cors设置,

解决办法很简单,直接在controller上加

@CrossOrigin

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。