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

在我服务器上
我开启后端代码
当我前端通过localhost:xx也能请求得到数据,为啥要在前端代码判断当前环境,生产环境用ip呢


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

1 Answer

localhost 可以简单看成 127.0.0.1,如果前端代码部署在当前机器上,那就没事,但如果在另一台呢?两者之间的通信就得通过本机 ip 来,建议参考这篇文章:https://blog.csdn.net/xifeiji...


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