#!/bin/bash

# Load environment variables
if [ -f .env ]; then
    export $(cat .env | grep -v '^#' | xargs)
fi

# Check if ORY_PROJECT_SLUG is set
if [ -z "$ORY_PROJECT_SLUG" ]; then
    echo "Error: ORY_PROJECT_SLUG not found in .env file"
    exit 1
fi

echo "Starting Ory tunnel for project: $ORY_PROJECT_SLUG"
echo "Tunnel will be available at: http://localhost:${TUNNEL_PORT:-4000}"
echo ""

npx @ory/cli tunnel --dev --project "$ORY_PROJECT_SLUG" http://localhost:${PORT:-3000}
