简体   繁体   English

如何从同一局域网内的另一台计算机访问 Big Sur 上的 localhost:4200(Angular App)?

[英]how to access localhost:4200 (Angular App) on Big Sur from another computer within the same lan?

screencapture : linksys port-forward table屏幕截图:linksys 端口转发表

My case is listed as below :我的情况如下:

  • The client computer and the server computer are on the same lan where the wifi router is : linksys model#ea6200客户端计算机和服务器计算机在wifi路由器所在的同一局域网上:linksys model#ea6200
  • The client computer can ping the server computer(where the server's OS is Big Sur 11.4 and its IP is 192.168.1.149)客户端电脑可以ping通服务器电脑(服务器的操作系统是Big Sur 11.4,IP是192.168.1.149)
  • The server is already listening to http://localhost:4200 , which is an Angular application .服务器已经在侦听 http://localhost:4200 ,这是一个 Angular 应用程序。
  • But , when I type http://192.168.1.149:4200 in the client's browser, the site can't be reached from the client's computer .但是,当我在客户端的浏览器中键入http://192.168.1.149:4200时,无法从客户端的计算机访问该站点。
  • I have checked that the Big Sur's firewall is off.我已经检查过 Big Sur 的防火墙是否关闭。

My Question is :我的问题是:

  1. What else should be further set so that the site on the server computer can be reached from the client's computer ?还应该进一步设置什么才能从客户端的计算机访问服务器计算机上的站点?
  2. Should I consider to make some configuration on the linksys port forwarding policy?我是否应该考虑对 linksys 端口转发策略进行一些配置?

Thanks.谢谢。

Answers from "NSteinbusch @ https://discord.davidbombal.com/ " :来自“NSteinbusch @ https://discord.davidbombal.com/ ”的回答:

  • this is an Angular issue rather than networking issue ;这是一个 Angular 问题而不是网络问题;
  • by default angular only listen on local interface 127.0.0.1 ;默认情况下,angular 只监听本地接口 127.0.0.1 ;
  • By using the cmd of “ng serve -- host 0.0.0.0” instead of simply typing “ng serve” to start the app, the client PC should be able to reach the Angular app of the server by http://192.168.1.149:4200/通过使用“ng serve -- host 0.0.0.0”的cmd而不是简单地输入“ng serve”来启动应用程序,客户端PC应该能够通过http://192.168.1.149访问服务器的Angular应用程序:4200/
  • By this method, the server will listen to all available interface, so your Ethernet NIC or Wi-Fi NIC as well.通过这种方法,服务器将侦听所有可用的接口,因此您的以太网网卡或 Wi-Fi 网卡也是如此。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 localhost:4200 不适用于我的 Angular 应用程序 - localhost:4200 not working for my angular app 无法从 localhost:4200 调用 API - Angular - Cannot call API from localhost:4200 - Angular 如何从 angular localhost:4200 调用 spring 安全 azure AD localhost:8080。 azure 调用出错 - How to call spring security azure AD localhost:8080 from angular localhost:4200. Error in azure call Angular 12 和 .NET 5, 来自 origin localhost:4200 的访问已被 CORS 策略阻止 With Windows Authentication - Angular 12 and .NET 5,access from origin localhost:4200 has been blocked by CORS policy With Windows Authentication Angular 9 和 .NET 核心 - 从源 localhost:4200 访问已被 CORS 策略阻止 - Angular 9 and .NET Core - access from origin localhost:4200 has been blocked by CORS policy 从源“http://localhost:4200”访问 XMLHttpRequest 已被 CORS 策略(Angular,WebApi)阻止 - Access to XMLHttpRequest from origin 'http://localhost:4200' has been blocked by CORS policy (Angular, WebApi) Angular 9:CORS 策略已阻止从来源“http://localhost:4200”访问位于“xxx”的 XMLHttpRequest - Angular 9: Access to XMLHttpRequest at 'xxx' from origin 'http://localhost:4200' has been blocked by CORS policy 在Angular 5中将localhost:4200更改为mysite:4200 - Change localhost:4200 to something mysite:4200 in Angular 5 启动角度应用程序时如何获取第一个 http 请求的标头 (http://localhost:4200/) - How get the header of the first http request when I launch an angular app (http://localhost:4200/) 带 Angular 的弹簧靴。 CORS 策略已阻止从源“http://localhost:4200”访问“http://localhost:8080/”处的 XMLHttpRequest - Spring boot with Angular. Access to XMLHttpRequest at 'http://localhost:8080/' from origin 'http://localhost:4200' has been blocked by CORS policy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM