Spaces:
Running
Running
File size: 1,477 Bytes
dec7538 0e58b9e dec7538 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/bin/sh
# ============================================================
# start-hf.sh - Startup script untuk Hugging Face Spaces
# Set BASE_URL otomatis dari environment SPACE_HOST HF
# ============================================================
# Fix DNS - override setiap container start (bukan di Dockerfile!)
echo "π Setting custom DNS resolvers..."
echo "nameserver 1.1.1.1" > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
echo "options timeout:2 attempts:3" >> /etc/resolv.conf
echo "β
DNS set: 1.1.1.1 (Cloudflare), 8.8.8.8 8.8.4.4 (Google)"
# Jika SPACE_HOST tersedia (otomatis dari HF Spaces), set BASE_URL
if [ -n "$SPACE_HOST" ]; then
export BASE_URL="https://${SPACE_HOST}"
export NEXT_PUBLIC_BASE_URL="https://${SPACE_HOST}"
echo "β
BASE_URL set to: $BASE_URL"
else
# Fallback jika tidak ada SPACE_HOST
export BASE_URL="http://localhost:7860"
export NEXT_PUBLIC_BASE_URL="http://localhost:7860"
echo "β οΈ SPACE_HOST not found, using localhost"
fi
export NEXT_PUBLIC_CLOUD_URL="https://9router.com"
export CLOUD_URL="https://9router.com"
echo "π Starting 9Router..."
echo " PORT : $PORT"
echo " BASE_URL : $BASE_URL"
echo " DATA_DIR : $DATA_DIR"
echo " NODE_ENV : $NODE_ENV"
echo ""
echo "π Dashboard : ${BASE_URL}/dashboard"
echo "π API : ${BASE_URL}/v1"
echo ""
# Start Next.js production server
exec npm run start |