其他分享
首页 > 其他分享> > Uniapp---报has been blocked by CORS policy:错误【解决办法】

Uniapp---报has been blocked by CORS policy:错误【解决办法】

作者:互联网

最近在用Uniapp开发项目,一直都是好好。但是突然报了一个神奇的错误:

Access to XMLHttpRequest at 'http://xxxx.xxxx.com/addons/Paper/api/v1/papers?is_over=false&loading=true&page=1&size=10' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

具体解决:

'Access-Control-Allow-Origin: *'
'Access-Control-Allow-Headers: Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With'

前端:需配置请求头

header: {
    'content-type':'application/x-www-form-urlencoded' 
},

打完收工!

标签:Control,Uniapp,Allow,Since,been,---,header,Access,blocked
来源: https://www.cnblogs.com/e0yu/p/16513683.html