谷歌应用商店搜索插件requestly(有个相似名称的插件,选择这个Requestly: Supercharge your Development & QA)
安装后打开插件网址https://app.requestly.io/rules/my-rules
新建规则rules->my rules-> new rule -> redirect request
配置 URL Contains xxxxx(需要转发的域名或者路径)
Replace xxxx(url中需要替换的字符串) With xxx(替换后的字符串,例如:http://localhost:80)
由于转发后未携带token,并且有跨域的现象,所以我在本地搭建了一个nginx
nginx配置如下
server {
listen 80 ;
location / {
# 处理预检请求 (OPTIONS)
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' '*' always;
add_header 'Access-Control-Allow-Headers' '*' always;
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
#add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' '*' always;
add_header 'Access-Control-Allow-Headers' '*' always;
proxy_set_header authorization 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJyYW5kb21LZXkiOiI2NzQxMWM';
proxy_pass http://localhost:39004/;
}
}
自此可以把测试环境的接口转发到本机的springboot项目中,使用测试的前端资源进行后台代码的调试