最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】vuejs中调用本地localhost的api报错:Access to XMLHttpRequest at from origin has been blocked by CORS policy

Access crifan 5609浏览 0评论
折腾:
【未解决】vue-admin-template中如何用vuejs去发送REST的api的POST请求并返回和解析json字符串
期间,去测试api调用,结果报错:
Access to XMLHttpRequest at 'http://localhost:8080/iec104/add/' from origin 'http://localhost:9528' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.22:41:12.455 request.js:43 errError: Network Error
22:41:12.457 :8080/iec104/add/:1 Failed to load resource: net::ERR_FAILED
22:41:12.458 createError.js:16 Uncaught (in promise) Error: Network Error
    at createError (createError.js:16)
    at XMLHttpRequest.handleError (xhr.js:69)
vuejs Access to XMLHttpRequest at from origin has been blocked by CORS policy
Has been blocked by CORS policy axios post – Get Help – Vue Forum
Blocked by CORS policy: No ‘Access-Control-Allow-Origin’ – Get Help – Vue Forum
Some axios request CORS not working – Get Help – Vue Forum
CORS issues with Vue example – Get Help – Vue Forum
No ‘Access-Control-Allow-Origin’ header is present – Get Help – Vue Forum
javascript – how to fix ‘Access to XMLHttpRequest has been blocked by CORS policy’ Redirect is not allowed for a preflight request only one route – Stack Overflow
此处,暂时从客户端入手
chrome浏览器,去试试
插件:Allow-Control-Allow-Origin
还是要从后端入手才行:
【已解决】给java的spring boot中后端加上CORS支持
然后就自然解决了此处问题了。

转载请注明:在路上 » 【已解决】vuejs中调用本地localhost的api报错:Access to XMLHttpRequest at from origin has been blocked by CORS policy

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.177 seconds, using 21.90MB memory