我也遇到了这个问题,其实就是不能用客户端访问,只能走服务端访问,跨域是只出现在浏览器上的。 如果你直接打开这个 https://api.weixin.qq.com/sns/oauth2/access_token?XXX 这个地址,你就会发现其实是可以正常获取信息的,所以改成写接口就行了
网页授权出现跨域问题,域名已经在公众平台配置XMLHttpRequest cannot load https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1b63f19b557665ec&redirect_uri=https%3A%2F%2Factivitygray.motivape.cn%2F%23%2Ffriends_index%3Fopenid%3D%26channelType%3D0&response_type=code&scope=snsapi_userinfo&state=?openid=&channelType=0#wechat_redirect. Redirect from 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1b63f19b557665ec&redirect_uri=https%3A%2F%2Factivitygray.motivape.cn%2F%23%2Ffriends_index%3Fopenid%3D%26channelType%3D0&response_type=code&scope=snsapi_userinfo&state=?openid=&channelType=0#wechat_redirect' to 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1b63f19b557665ec&redirect_uri=https%3A%2F%2Factivitygray.motivape.cn%2F%23%2Ffriends_index%3Fopenid%3D%26channelType%3D0&response_type=code&scope=snsapi_userinfo&state=?openid=&channelType=0&connect_redirect=1#wechat_redirect' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://activitygray.motivape.cn' is therefore not allowed access. [图片]
2023-06-26