Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

假设服务器公网地址是 122.33.21.3
服务器部署了一个web服务在80端口
在服务器上有一个后端服务在7001端口

当用户访问122.33.21.3:80的时候
前端的请求base是localhost:7001

这样写的话 用户在本地打开 请求是用户电脑7001端口还是远程服务器的7001端口?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.4k views
Welcome To Ask or Share your Answers For Others

1 Answer

请求的是你本地的,即用户电脑的7001端口。
你要想访问服务器的7001的话,调接口的时候不加localhost,比如调http://122.33.21.3/api,你代码里就写/api,不要写http://localhost/api


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...