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應用等)跨域