如何将dart frog服务器的ip从www.example.com更改127.0.0.1为0.0.0.0(或实际的LAN ip)

disho6za  于 2023-02-27  发布在  其他
关注(0)|答案(1)|浏览(184)

对于Dart Frog服务器,我可以使用以下命令启动它

dart_frog dev --port 8090

但是它只能从127.0.0.1:8090访问,
我希望使用本地IP(例如www.example.com)从同一局域网中的其他计算机上获得它192.168.0.10,因此希望指定0.0.0.0
但却找不到改变它的方法。

2nbm6dog

2nbm6dog1#

无论在哪里调用serve,第二个参数似乎可以是各种各样的东西,包括'0.0.0.0':https://pub.dev/documentation/dart_frog/latest/dart_frog/serve.html。向下搜索,我们最终找到的地址为:

/// The [address] can either be a [String] or an
  /// [InternetAddress]. If [address] is a [String], [bind] will
  /// perform a [InternetAddress.lookup] and use the first value in the
  /// list. To listen on the loopback adapter, which will allow only
  /// incoming connections from the local host, use the value
  /// [InternetAddress.loopbackIPv4] or
  /// [InternetAddress.loopbackIPv6]. To allow for incoming
  /// connection from the network use either one of the values
  /// [InternetAddress.anyIPv4] or [InternetAddress.anyIPv6] to
  /// bind to all interfaces or the IP address of a specific interface.

看起来你想要InternetAddress.anyIPv4作为你的值。

相关问题