#!/bin/sh echo "===== Application Startup at $(date) =====" # Set NEXTAUTH_URL based on SPACE_HOST if available if [ -n "$SPACE_ID" ]; then echo "Setting NEXTAUTH_URL to https://${SPACE_HOST}" export NEXTAUTH_URL="https://${SPACE_HOST}" else echo "WARNING: SPACE_ID not found" fi # Use Neon PostgreSQL database (no local setup needed) export DATABASE_URL="postgresql://neondb_owner:npg_Qq0B1uWRXavx@ep-steep-dream-adqtvjel-pooler.c-2.us-east-1.aws.neon.tech:5432/neondb?sslmode=require" # Export these environment variables to influence Next.js binding export HOSTNAME="0.0.0.0" export HOST="0.0.0.0" export PORT=3000 # Disable CSP headers to allow for embedded use within HF export LANGFUSE_CSP_DISABLE="true" # Preset oauth env vars based on injected space variables # See https://huggingface.co/docs/hub/en/spaces-oauth#create-an-oauth-app export AUTH_CUSTOM_CLIENT_ID=$OAUTH_CLIENT_ID export AUTH_CUSTOM_CLIENT_SECRET=$OAUTH_CLIENT_SECRET export AUTH_CUSTOM_ISSUER=$OPENID_PROVIDER_URL export AUTH_CUSTOM_SCOPE=$OAUTH_SCOPES export AUTH_CUSTOM_NAME="Hugging Face" # Disable authentication via username/password to enforce authentication via HF export AUTH_DISABLE_USERNAME_PASSWORD="true" # Pass through AUTH_DISABLE_SIGNUP value if set, default to false if not set if [ -n "$AUTH_DISABLE_SIGNUP" ]; then export AUTH_DISABLE_SIGNUP="$AUTH_DISABLE_SIGNUP" else export AUTH_DISABLE_SIGNUP="false" fi # Test database connection echo "Testing database connection..." if command -v pg_isready > /dev/null 2>&1; then if pg_isready -h ep-steep-dream-adqtvjel-pooler.c-2.us-east-1.aws.neon.tech -p 5432; then echo "Database connection successful!" else echo "Database connection failed, but proceeding anyway..." fi else echo "pg_isready not available, skipping connection test..." fi # Start Langfuse echo "Starting Langfuse..." exec ./web/entrypoint.sh node ./web/server.js --keepAliveTimeout 110000