Flutter web服务器仅在localhost:8080上可访问,如何启用局域网访问?

huangapple go评论59阅读模式
英文:

Flutter web server only accessible on localhost:8080, how to enable LAN access?

问题

问题:Flutter web不允许相同的LAN设备IP连接。

描述:本地计算机可以通过192.168.1.x:8080或localhost:8080连接到网站,但无法通过连接到LAN的另一部手机登录网页。我已经尝试了Nodejs服务器,没有这个问题。

背景环境:
操作系统:iOS
Flutter版本:3.7.0

迄今为止尝试的方法:

  1. 运行命令:flutter run -d web-server --web-hostname 0.0.0.0 --web-port 8080
  2. 关闭防火墙。

我希望他能让我在与Nodejs服务器相同的本地区域网络中访问网页。

英文:

I am a novice and I have a question I would like to ask you.

Problem:
flutter web does not allow the same LAN device ip to connect.

Description:
The local computer can connect to the website through 192.168.1.x:8080 or localhost:8080, but it cannot log in to the webpage with another mobile phone connected to the LAN. I have tried Nodejs server, and there is no such problem.

Background environment:
Operating system: IOS
flutter version: 3.7.0

Tried so far:
1. flutter run -d web-server --web-hostname 0.0.0.0 --web-port 8080
2. Firewall off.

I expect him to be able to allow me to access web pages in the same local area network as Nodejs server.

答案1

得分: -2

将本地主机名更改为您的IP地址:

flutter run -d web-server --web-hostname (在此处填写IP) --web-port 8080

如果这不起作用,请尝试这个链接:
https://medium.com/@TheOlajos/lan-cross-platform-application-using-xampp-and-flutter-markup-language-in-under-10-minutes-1b5151cc7525

英文:

Change your localhost name to your IP address:

flutter run -d web-server --web-hostname (IP here) --web-port 8080

If that doesn't work, try this:
https://medium.com/@TheOlajos/lan-cross-platform-application-using-xampp-and-flutter-markup-language-in-under-10-minutes-1b5151cc7525

huangapple
  • 本文由 发表于 2023年5月21日 10:20:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76298044.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定