账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    egg前后端分离项目中关于微信验证如何处理跨域问题
    38
    0

    项目为前后端分离,前段打包成x.html静态文件,结合x.css,x.js

    egg众多配置都完成,跨域访问成功.....com/x.html#/user 可以成功获取到数据
    问题来了,微信验证需要后端重定向
    this.ctx.redirect('https://open.weixin.qq.com/connect/oauth2/authorize?appid='+AppID+'&redirect_uri='+return_uri+'&response_type=code&scope='+scope+'&state=STATE#wechat_redirect');
    这个return_uri的参数为...com/oauth,那么前端页面访问这个url会提示跨域

    XMLHttpRequest cannot load https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxx&;redirect_uri=xxxxxxx&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect. Redirect from 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxx&redirect_uri=xxxxxxxxx&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect' to 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxx&redirect_uri=xxxxxxx&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'xxxxxxxx' is therefore not allowed access.
    
    
    axios中也做了跨域设置,仍然无效,请教大牛!
    
    
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • KYIK爱你 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部