微信公众号授权回调 vue网址中带#号的处理

1、改变vue模式为history,小编没有试

2、通过配置nginx实现

      A、替换跳转网址中的#为其他字符串,例如我的

       

复制代码
        const url = this._getUrl(
            "https://open.weixin.qq.com/connect/oauth2/authorize", {
                appid: this.appId,
                redirect_uri: encodeURIComponent(
                    location.href.replace("#", "virtually")
                ),
                response_type: "code",
                scope: this.scope,
                state: this.state,
            }
        );
        location.href = `${url}#wechat_redirect`;
        console.log("完整的Url");
        console.log(location.href);
复制代码

   我替换成了virtually,这样返回的时候就是正常的返回了。

2、在nginx中配置跳转

      

location / {
    rewrite ^/virtually/(.*)$ /#$1 permanent;
}

   重启下nginx,搞定。调试只能用微信开发者工具调试了

posted @   郑州谷多软件  阅读(1211)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示