当前位置:网站首页>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 ?
边栏推荐
- The National University of Singapore 𞓜 uses model free reinforcement learning to evaluate the energy efficiency of the energy efficiency data center
- ABAP随笔-关于ECC后台server读取Excel方案的想法
- MySQL删除表后如何使ID从1开始
- Arcgis-engine二次开发之空间关系查询与按图形查询
- 陈云pytorch学习笔记_用50行代码搭建ResNet
- 居家办公竟比去公司上班还累?
- 移动端避免使用100vh[通俗易懂]
- Redis principle - string
- 因美纳陷数据泄露“丑闻”:我国基因数据安全能交给美企吗?
- Livox Lidar+APX15 实时高精度雷达建图复现整理
猜你喜欢

Feign通过自定义注解实现路径的转义
![[Blue Bridge Cup training 100 questions] scratch digital calculation Blue Bridge Cup competition special prediction programming question collective training simulation exercise question No. 16](/img/7c/d4ea8747ce45fd2eb59a8f968653db.png)
[Blue Bridge Cup training 100 questions] scratch digital calculation Blue Bridge Cup competition special prediction programming question collective training simulation exercise question No. 16

Detect objects and transfer images through mqtt

最新云开发微信余额充电器特效小程序源码

MySQL十八:写语句的执行过程

First principles (optimal solution theory)

基于 ESXi 的黑群晖 DSM 7.0.1 安装 VMware Tools

vivado VIO IP的用法

This kind of people began to be robbed by VC with a monthly salary of 80000 yuan

【蓝桥杯集训100题】scratch数字计算 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第16题
随机推荐
Using xgboost with tidymodels
[essay]me53n add button to call URL
seata
使用SQL进行数据去重的N种方法
实践torch.fx:基于Pytorch的模型优化量化神器
[js]var, let, const
Arcgis-engine二次开发之空间关系查询与按图形查询
Design of STM32 and rc522 simple bus card system
Discuz小鱼游戏风影传说商业GBK+UTF8版模板/DZ游戏网站模板
移动端避免使用100vh[通俗易懂]
Is the dog virtue training with a monthly salary of 30000 a good business?
SQL Server 2016详细安装教程(附注册码和资源)
[electron] basic learning
跨系统数据一致性问题解决方案汇总
Hiplot 在線繪圖工具的本地運行/開發庫開源
MySQL十八:写语句的执行过程
[从零开始学习FPGA编程-48]:视野篇 - 智能传感器的发展与应用
OData - API using SAP API hub in SAP S4 op
Started a natural language model bloom
[electron] 基础学习