Skip to content
Snippets Groups Projects
.env.local 1.35 KiB
#!/bin/sh

# Configuration file containing e.g. backend URLs, **no secrets**. Use .envrc.local for secrets.

# depending on the execution environment, DEV_HOST must use a different value for the frontend to be able to connect to the backends
# - for web and iOS simulator use "localhost" or actual local ip address (host) (platform-specific)
# - for real device use actual local ip address (host) (platform-specific)
# - for Android emulator use 10.0.2.2
get_local_ip_linux() {
  default_device=$(ip route | grep default | awk '{print $5}')
  ip addr show dev "$default_device" | grep -oP 'inet \K[\d.]+'
}
get_local_ip_macos() {
  default_device=$(netstat -rn | grep default | grep -v utun | head -n 1 | awk '{print $4}')
  ipconfig getifaddr "$default_device"
}
#DEV_HOST=10.0.2.2
if [ "$DEV_HOST" = "" ]; then
  if [ "$(uname)" = "Linux" ]; then
    DEV_HOST=$(get_local_ip_linux)
  elif [ "$(uname)" = "Darwin" ]; then
    DEV_HOST=$(get_local_ip_macos)
  else
    echo "Could not determine the local IP address. Please provide it yourself in .env.local"
    exit 1
  fi
  echo "Determined the local IP to be $DEV_HOST. If this is not correct, please provide it yourself in .env.local"
fi
export DEV_HOST

export HOLI_CHAT_SERVER_NAME=local.chat.holi.social
export HOLI_CHAT_SERVER_URL=http://${DEV_HOST}:8008
export HOLI_CHAT_PUSH_GATEWAY_URL=http://chat-push-gateway:5000