微信内外网映射

两种方法是可以行的:

  1. 使用ngrok,直接使用 ngrok http 8080就可以
  2. 安装 node.js的 localtunnel模块,执行 lt --port 8080命令就行

http-server 用法 配置项如下

-p
Port to use (defaults to 8080)
-a
Address to use (defaults to 0.0.0.0)
-d
Show directory listings (defaults to 'True')
-i
Display autoIndex (defaults to 'True')
-g
or --gzip
When enabled (defaults to 'False') it will serve ./public/some-file.js.gz
in place of ./public/some-file.js
when a gzipped version of the file exists and the request accepts gzip encoding.
-e
or --ext
Default file extension if none supplied (defaults to 'html')
-s
or --silent
Suppress log messages from output
--cors
Enable CORS via the Access-Control-Allow-Origin
header
-o
Open browser window after starting the server
-c
Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds (defaults to '3600'). To disable caching, use -c-1.
-U
or --utc
Use UTC time format in log messages.
-P
or --proxy
Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com
-S
or --ssl
Enable https.
-C
or --cert
Path to ssl cert file (default: cert.pem).
-K
or --key
Path to ssl key file (default: key.pem).
-r
or --robots
Provide a /robots.txt (whose content defaults to 'User-agent: *\nDisallow: /')
-h
or --help
Print this list and exit.

我是华丽的分割线


终于把测试号配置成功了不容易啊!!!鸡冻

就这个页面

看着那里的url和token没本法啊

url:你的链接必须暴露在外网,微信服务器才能找到,所以需要这个东西,没有怎么办,那就造一个,像上文说的 ngrok就提供了外网映射,执行ngrok http 3000就可以映射你的localhost:3000端口了

token:这个是自定义的,要和微信服务器上的一致


这一过程发生了什么呢?

微信服务器会向你的服务器(就是你填写的那个url)发送经过加密的东东,具体规则看这里 如何验签

好了,然后你本地启动一个实现该验签功能的服务器,当然你只启动已一个什么都不干的http-server是必须不行的

用express吧

具体代码在这里

主要是common/utils.js实现验证签名功能

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • =========================================================...
    lavor阅读 3,508评论 0 5
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,562评论 5 6
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,001评论 19 139
  • 作者:王吟旭 冬天又到了。 不管走到哪,都觉得下雪的天越来越少了。说起下雪,我总忘不了初中时候的冬天 ,那时的冬天...
    晖说阅读 624评论 0 0
  • 转自看,在日常的开发当中,当一个项目在开发过程中或者完成准备上线,都需要我们进行真机测试,否则不可能开发完了就直接...
    超_iOS阅读 2,511评论 0 2