#!/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