File size: 670 Bytes
df97757 2d1ebb2 4882aa6 df97757 aedd22f 15611b7 aedd22f 15611b7 aedd22f df97757 aedd22f df97757 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #!/bin/bash
set -e
SUBDOMAIN=${LT_SUBDOMAIN:-vercel}
# Start g4f API server in background
python -m g4f --port 7860 &
G4F_PID=$!
sleep 2
echo "Creating public tunnel..."
# Try with the requested subdomain first
if npx localtunnel --port 7860 --print-requests --subdomain "${SUBDOMAIN}"; then
echo "Tunnel established: https://${SUBDOMAIN}.loca.lt"
else
echo "Subdomain '${SUBDOMAIN}' is taken or an error occurred. Falling back to random subdomain..."
# Now let localtunnel generate a random subdomain (blocking call)
npx localtunnel --port 7860 --print-requests
fi
# Cleanup when the tunnel exits
kill $G4F_PID 2>/dev/null
wait $G4F_PID 2>/dev/null |