谷歌應用商店搜索插件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項目中,使用測試的前端資源進行后臺代碼的調試