微信公眾號掃一掃功能提示:10003 redirect_uri域名與后台不一致
Senparc.Weixin組件很好用,但一個坑,不知道這和個是否有關。。
先說明下環境,centos+.net core 2.2
.netcore 直接dotnet run ,用nohup運行起來,配置端口為80,UseUrls("http://*:80")。 運行命令是: nohup dotnet run &
沒有配置nginx前,一切正常!!!!
配置端口號為8081后(UseUrls("http://*:8081")),再配置上nginx轉發后,偶發性的出現:“10003 redirect_uri域名與后台不一致”
配置代碼如下:
upstream changdao {
server 127.0.0.1:8081;
}
server {
listen 80;
server_name changdao.xxxxx.org;
location /{
proxy_pass http://changdao;
}
}
經過調試,發現最近最終回調變成了
https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxbb437396db00ae95&redirect_uri=http%3A%2F%2Fchangdao%2FPortalWeb
redirect_uri這個值變了,,變成如下。
http://changdao/PortalWeb
這是什么鬼???
看的有點眼熟啊,,原來是nginx配置中的那個鬼。
upstream changdao
思路有了改了下“upstream”的名字,改成了 :changdao.xxxxx.org ,配置代表如下:
upstream changdao.xxxxx.org {
server 127.0.0.1:8081;
}
server {
listen 80;
server_name changdao.xxxxx.org;
location /{
proxy_pass http://changdao.xxxxx.org;
}
改完nginx配置后,用下面命令檢查下是配置否正常
/usr/local/nginx/sbin/nginx -t
重啟nginx:
cd /usr/local/nginx/sbin/nginx
./nginx -s reload
再次測試,問題解決
