Wechat shows that the scope parameter can not be empty, because it is a single page application, there is the problem of-sharp number?

problem description


VUE-sharp
www.abc.com
https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxx&redirect_uri=http://www.abc.com/&response_type=code&scope=snsapi_userinfo

https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxx&redirect_uri=http://www.abc.com/login/&response_type=code&scope=snsapi_userinfo

http://www.abc.com/-sharp/login/-sharpscope
history-sharp


Apr.26,2021

use encodeURIComponent () to transcode

const uri = encodeURIComponent(window.location.href.split('?')[0]);
window.location.href = `${this.$store.state.appWechat.gateway}?redirect_uri=${uri}&state=wechat`;
< hr >

after answering the question, I remembered that my authentication API was centrally processed by the backend gateway in order to deal with the authentication of multiple domain names. This uri is cached on the server side and is not sent directly to Wechat's authentication link, so it is not sure that it is feasible.

Menu