Don't crash when running the preview server and not connected to any network (no public IP)
This commit is contained in:
parent
08dee580aa
commit
9f5080edf9
|
@ -272,7 +272,8 @@ module Middleman
|
|||
# An IPv4 address on this machine which should be externally addressable.
|
||||
# @return [String]
|
||||
def public_ip
|
||||
Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address
|
||||
ip = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }
|
||||
ip ? ip.ip_address : '127.0.0.1'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue