authtoken
natapp.exe
natapp -authtoken=上文提到的authtoken
。命令行会出现相似Forwarding http://smalle.natappfree.cc -> 127.0.0.1:80
的显示。(表示访问在浏览器中访问http://smalle.natappfree.cc时至关于本地访问127.0.0.1:80)
D:/software/natapp.exe -authtoken=12347dc3f25a1234
本地项目是基于nginx反向代理服务器实现(apache也可)html
下载nginx并安装,配置nginx.conf
文件,如:nginx
server { listen 80; server_name localhost; location / { root C:/Users/smalle/Desktop/web; index index.html index.htm; }
启动nginx(此时可经过http://127.0.0.1或http://smalle.natappfree.cc访问)web
MP_verify_2DCaFsV02WRKw123.txt
的文件下载到root路径下xyabcd.natappfree.cc
(不须要http://)保存便可若是api和web项目分别部署,如web是用nginx静态服务器,api使用PHP/Java完成。就回出现跨域问题,此处可在nginx中再次配置后台api的转发apache
location /api/ { proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://127.0.0.1:8080; break; } }
web项目中认证请求js如:http://smalle.natappfree.cc/api/auth?code=021GT83e1ucjUu035F0e1Ttg3e1GT812
就会被转发到http://127.0.0.1:8080/api/auth?code=021GT83e1ucjUu035F0e1Ttg3e1GT812
api
var url = "http://smalle.natappfree.cc/api/auth?code=" + code; $.get(url, function(res) { console.log(res); });
相关文章:服务号使用微信网页受权(H5应用等)跨域