收藏
回答

为什么无法获取code?

前后端设置都是一样的  为什么还提示   错误码:10003

const appId = 'wxc2bd5c73204be4f8';

const redirectUri = encodeURIComponent("http://zhaofei.online/Home/Login");

const authUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";

console.log("跳转授权地址:", authUrl); // 调试用,查看实际跳转地址

window.location.href = authUrl;


服务号:民航招飞

回答关注问题邀请回答
收藏

3 个回答

  • Mr.Zhao
    Mr.Zhao
    2025-11-07

    js 模板语法都不会啊,是反引号

    2025-11-07
    有用 1
    回复 6
    • 刘大帅 民航招飞
      刘大帅 民航招飞
      2025-11-07
      网站代码都没动过,前台还是正常使用的,昨天换了服务器就不能正常使用了。
      2025-11-07
      回复
    • Mr.Zhao
      Mr.Zhao
      2025-11-07回复刘大帅 民航招飞
      你把oauth2地址发出来  不要带变量,谁知道你有没有动过
      2025-11-07
      回复
    • 刘大帅 民航招飞
      刘大帅 民航招飞
      2025-11-07
      const appId = "wxc2bd5c73204be4f8";
         const redirectUri = encodeURIComponent('http://zhaofei.online/Home/Login');
         const authUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect`;
         window.location.href = authUrl;
      2025-11-07
      回复
    • Mr.Zhao
      Mr.Zhao
      2025-11-07回复刘大帅 民航招飞
      自己都不试试吗  这不是行吗
      2025-11-07
      回复
    • 刘大帅 民航招飞
      刘大帅 民航招飞
      2025-11-07
      还是不行,还是显示1003. 但是刚刚HIxuan登录我们服务器获得到他的code了,阿白,这个就很奇怪了,所有想看看HIxuan用的是什么代码。
      2025-11-07
      回复
    查看更多(1)
  • Hlxuan.
    Hlxuan.
    2025-11-07

    用模板字符串语法,这里不应该是用 ` 反引号吗?

    我刚试了下,网页授权没有复现 10003 的问题呀。

    url参数不是传code了?

    2025-11-07
    有用 1
    回复 6
    • 刘大帅 民航招飞
      刘大帅 民航招飞
      2025-11-07
      什么反引号都试过了,一样不行
      2025-11-07
      回复
    • 刘大帅 民航招飞
      刘大帅 民航招飞
      2025-11-07
      我这边回复我
      2025-11-07
      回复
    • 刘大帅 民航招飞
      刘大帅 民航招飞
      2025-11-07
      刚才您的请求 服务器 拿到了  麻烦您把代码贴一下
      2025-11-07
      回复
    • 心蓝
      心蓝
      2025-11-07
      const appId = "wxc2bd5c73204be4f8";
         const redirectUri = encodeURIComponent('http://zhaofei.online/Home/Login');
         const authUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect`;
         window.location.href = authUrl;
      2025-11-07
      回复
    • 心蓝
      心蓝
      2025-11-07回复心蓝
      这个代码就不行,单引号 双引号 反引号都试过了,没用。想通的代码别的项目就没问题,很是无语。
      2025-11-07
      回复
    查看更多(1)
  • 刘大帅 民航招飞
    刘大帅 民航招飞
    2025-11-07

    现在就是我这边请求微信接口获取code,微信也接收到了我的请求并且回调到了我的login接口,但是并没有给我code。

    并且还提示前后域名不一致,我都有截图,明明一致

    2025-11-07
    有用
    回复
登录 后发表内容