使用localhost和127.0.0.1都可以访问接口,比如:
http://localhost:8080/zhgl/login/login-fy-list
或者
http://127.0.0.1:8080/zhgl/login/login-fy-list
返回json
{"_code":10000,"_msg":"Success","_data":[{"fymc":"XXXX","fydm":0,"sjdm":-1,"xjfyList":[]}],"_timestamp":1696684253493}
而使用
http://192.168.3.4:8080/zhgl/login/login-fy-list
使用curl -i 测试
sunyuhua@sunyuhua-HKF-WXX:~$ curl -v http://192.168.3.4/
* Uses proxy env variable no_proxy == 'localhost,127.0.0.0/8,::1'
* Uses proxy env variable http_proxy == 'http://127.0.0.1:7890/'
* Trying 127.0.0.1:7890...
* Connected to (nil) (127.0.0.1) port 7890 (#0)
> GET http://192.168.3.4/ HTTP/1.1
> Host: 192.168.3.4
> User-Agent: curl/7.81.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 502 Bad Gateway
< Connection: keep-alive
< Keep-Alive: timeout=4
< Proxy-Connection: keep-alive
< Content-Length: 0
<
* Connection #0 to host (nil) left intact
可以看出走的是系统代理
打开系统设置,进行忽略主机设置,把本地的地址加上去
再次访问,可以正常的返回。
http://192.168.3.4:8080/zhgl/login/login-fy-list