当前位置:网站首页>Applet referer
Applet referer
2022-06-27 23:24:00 【Cloud idle】
How the applet is based on referer Jump to different background environments
This article mainly explains “ How the applet is based on referer Jump to different background environments ”, The explanation in the text is simple and clear , Easy to learn and understand , Next, please follow Xiaobian's ideas and go deeper slowly , Study and learn together “ How the applet is based on referer Jump to different background environments ” Well !
One 、 problem :
When developing small programs 4 A version ( Development 、 Experience 、 to examine 、 formal ). So different environments require different backgrounds . Especially the audit version , Because wechat audit is also required , If the request is wrong , It's going to fail . Because the production environment corresponds to the old background version , Therefore, the approval version cannot be transferred to the background production environment , You can't jump to the development environment .
For the convenience of production 、 to examine 2 Each version of the applet requests /prod. Here, it is necessary to distinguish between the real request and the production request 、 Where did the audit come from .
Two 、 Solutions .
Wechat sends requests to our servers wx.request I'll take one with me referer Of header Parameters . The format is as follows :
https://servicewechat.com///page-frame.html
among <appId> It's the applet that sends the request appId,<version> It's the version of the applet .
Development 、 Experience 、 to examine In the version version The value is 0, Development tools version The value is devtools.
The official version of version Value is greater than 0 The positive integer , Indicates how many times the applet has been released to the official version . Examples are as follows :
Development Edition :
https://servicewechat.com/ Applet appId/0/page-frame.html
Experience version :
https://servicewechat.com/ Applet appId/0/page-frame.html
devtools:
https://servicewechat.com/ Applet appId/devtools/page-frame.html
Official version :
https://servicewechat.com/ Applet appId/6/page-frame.html
3、 ... and 、 Solution . adopt nginx Make server selection .
1、 Define a variable foo, To configure a map, hold http_referer Mapping to foo.
map $http_referer $foo {
default "prod";
~^https://servicewechat.com/[^/]+/0/(.*)$ "dev";
~^https://servicewechat.com/[^/]+/devtools/(.*)$ "dev";
}
2、 Configure server .
upstream dev {
server localhost:7777;
}
upstream prod {
server localhost:9999;
}
3、location Use in foo Variable , Navigate to the correct address .
Here I use add_header hold foo Variable output , As a test .
location / {
#set $foo "$http_referer";
add_header wkfoo 'foo: $foo "$http_referer"';
proxy_pass http://$foo;
}
4、 Test it .
curl -H 'Cache-Control: no-cache' -I "https://xxx.xxx.com/prod/xxx? Parameters 1=xxx& Parameters 2=xxx" --referer "https://servicewechat.com/xxx/devtools/page-frame.html"
curl -H 'Cache-Control: no-cache' -I "https://xxx.xxx.com/prod/xxx? Parameters 1=xxx& Parameters 2=xxx" --referer "https://servicewechat.com/xxx/0/page-frame.html"
Is it necessary to set the applet referer?


It seems that unless you open a web page in an applet And the applet can't bring it automatically cookie token It seems that you can't be attacked ?
边栏推荐
- [从零开始学习FPGA编程-48]:视野篇 - 智能传感器的发展与应用
- Brief introduction to game phone platform
- [Blue Bridge Cup training 100 questions] scratch digital calculation Blue Bridge Cup competition special prediction programming question collective training simulation exercise question No. 16
- 用pytorch进行CIFAR-10数据集分类
- 游戏手机平台简单介绍
- clickonce 部署ClickOnce应用程序时出错-清单中的引用与下载的程序集的标识不匹配
- Discuz small fish game wind shadow legend business gbk+utf8 version template /dz game website template
- 跨系统数据一致性问题解决方案汇总
- EasyCVR平台路由日志功能的技术实现过程【附代码】
- vivado VIO IP的用法
猜你喜欢

华为伙伴暨开发者大会2022 | 麒麟软件携手华为共建计算产业,共创数智未来

Netease cloud lost its "feelings" card

Feign implements path escape through custom annotations

The most illusory richest man in China is even more illusory

Stream + Nacos

Is the dog virtue training with a monthly salary of 30000 a good business?

良/恶性乳腺肿瘤预测(逻辑回归分类器)

seata

Advertising is too "wild", Yoshino "surrenders"

The latest cloud development wechat balance charger special effect applet source code
随机推荐
golang - new和make的区别
Is it safe to use flush mobile phones to speculate in stocks?
Spark BUG實踐(包含的BUG:ClassCastException;ConnectException;NoClassDefFoundError;RuntimeExceptio等。。。。)
mongodb基础操作之聚合操作、索引优化
clickonce 部署ClickOnce应用程序时出错-清单中的引用与下载的程序集的标识不匹配
各种loam总结(激光slam)
Brief introduction to game phone platform
[网络]常见的请求方法
UESTC (shenhengtao team) & JD AI (Mei Tao team) proposed a structured dual stream attention network for video Q & A, with performance SOTA! Better than the method based on dual video representation!
Summary of solutions to cross system data consistency problems
MySQL删除表后如何使ID从1开始
[Blue Bridge Cup training 100 questions] scratch digital calculation Blue Bridge Cup competition special prediction programming question collective training simulation exercise question No. 16
云辅助隐私集合求交(Server-Aided PSI)协议介绍:学习
ABAP随笔-物料主数据界面增强-页签增强
The most illusory richest man in China is even more illusory
因美纳陷数据泄露“丑闻”:我国基因数据安全能交给美企吗?
Design of STM32 and rc522 simple bus card system
Go语言fsnotify接口实现监测文件修改
Azure Kinect DK realizes 3D reconstruction (PC non real time version)
【数字IC/FPGA】检测最后一个匹配序列的位置