微信小程序 webview 加载 h5 无法打开该页面

820 阅读1分钟

出现情况

uniapp 开发微信小程序,webview加载一个h5,iPhone体验环境可以打开,安卓打不开

image.png

过程

看到这个页面首先想到小程序管理后台配置业务域名

配置文件当然也要放到部署后的程序文件里,保证业务域名根目录下能访问到

但,我这个还是不行

解决

发现我设置的域名是 https:// ,但安卓机被跳转到了 http://

那就找 nginx 配置内容吧

server {
	listen       80;
	server_name  www.syxt.com;

	add_header Access-Control-Allow-Origin "$http_origin";
	add_header Access-Control-Allow-Methods 'GET,POST';
	add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
	#charset koi8-r;
	access_log  /var/log/nginx/host.access.log  main;
	error_log  /var/log/nginx/error.log  error;

	# 防止重定向 https 被改成 http
	absolute_redirect off;
}