请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

远程代理接口报错

源请求:

https://weibo.com/aj/v6/comment/small?ajwvr=6&act=list&mid=4247696808441951&uid=6567351113&isMain=true&dissDataFromFeed=%5Bobject%20Object%5D&ouid=2609660273&location=v6_content_home&group_source=group_all&rid=2_0_8_3080946866545731936_0_0&_t=0&__rnd=1528229322805

配置内容:

$.get('/aj/v6/comment/small', {

ajwvr:6,

act:'list',

mid:4247696808441951,

uid:6567351113,

isMain:true,

dissDataFromFeed:'%5Bobject%20Object%5D',

ouid:2609660273,

location:'v6_content_home',

group_source:'group_all',

rid:'2_0_8_3080946866545731936_0_0',

_t:0,

__rnd:1528229322805,

},function(data){

console.log(data)

})


proxy: {

'/aj':{

target: 'https://weibo.com',

changeOrigin: true

}

},

报错内容:Failed to load https://passport.weibo.com/visitor/visitor?entry=miniblog&a=enter&url=https%3A%2F%2Fweibo.com%2Faj%2Fv6%2Fcomment%2Fsmall%3Fajwvr%3D6%26act%3Dlist%26mid%3D4247696808441951%26uid%3D6567351113%26isMain%3Dtrue%26dissDataFromFeed%3D%25255Bobject%252520Object%25255D%26ouid%3D2609660273%26location%3Dv6_content_home%26group_source%3Dgroup_all%26rid%3D2_0_8_3080946866545731936_0_0%26_t%3D0%26__rnd%3D1528229322805&domain=.weibo.com&sudaref=http%3A%2F%2Flocalhost%3A9001%2F&ua=php-sso_sdk_client-0.6.28&_rand=1528230119.842: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9001' is therefore not allowed access.

正在回答 回答被采纳积分+3

1回答

qbaty 2018-06-06 11:41:19

这个是新浪微博的接口跳转,因为你没有登录新浪微博,也没有他的cookie 

0 回复 有任何疑惑可以回复我~
  • 提问者 慕无忌6890528 #1
    我登录了微博了。而且我试着在百度上去一个网站上拿数据,也是提示同样的错误。
    回复 有任何疑惑可以回复我~ 2018-06-06 15:53:14
  • 提问者 慕无忌6890528 #2
    刚刚试了一下,加上cookie请求成功了。这是为啥?有点懵啊。感觉这样不是解决跨域问题啊。我的微博已经登录,查看的他人文章,拿取的请求链接,但是不加cookie就报上面的错,希望老师解惑。万分感谢。
    回复 有任何疑惑可以回复我~ 2018-06-06 16:45:43
  • qbaty 回复 提问者 慕无忌6890528 #3
    因为虽然在浏览器上登录了,但是你不是用浏览器请求的新浪微博,你是用node 服务器请求的,你得cookie 在node 服务器上还没有啊
    回复 有任何疑惑可以回复我~ 2018-06-07 13:59:53
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信