# How to Test Health API Through Domain: aibitadmin.aibitsoft.cloud

## Current Status

✅ **Application is running** on port 4001  
✅ **PM2 process:** `aibitadmin-backend` (online)  
⚠️ **Domain proxy:** Needs configuration in cPanel

## Method 1: Test via Browser (Easiest)

### Step 1: Open Your Browser

Navigate to:
```
https://aibitadmin.aibitsoft.cloud/api/health
```

or

```
http://aibitadmin.aibitsoft.cloud/api/health
```

### Step 2: Expected Response

You should see:
```json
{
  "status": "ok",
  "timestamp": "2026-03-06T11:15:58.210Z",
  "environment": "production"
}
```

## Method 2: Test via Command Line (curl)

### On Your Local Computer:

```bash
# Test HTTP
curl http://aibitadmin.aibitsoft.cloud/api/health

# Test HTTPS (recommended)
curl https://aibitadmin.aibitsoft.cloud/api/health

# Pretty print JSON response
curl -s https://aibitadmin.aibitsoft.cloud/api/health | jq .
```

### On the Server:

```bash
# Test from server
curl http://aibitadmin.aibitsoft.cloud/api/health
curl https://aibitadmin.aibitsoft.cloud/api/health
```

## Method 3: Configure cPanel Node.js Selector (Recommended)

Since you're on cPanel shared hosting, the best way is to use **Node.js Selector**:

### Steps:

1. **Log into cPanel**
   - Go to your cPanel dashboard

2. **Find "Node.js Selector" or "Setup Node.js App"**
   - Look in the "Software" section
   - Or search for "Node.js" in cPanel search

3. **Create New Node.js Application:**
   - Click "Create Application" or "Setup Node.js App"
   - Fill in the details:
     ```
     Node.js Version: 20.x (or latest LTS)
     Application Mode: Production
     Application Root: /home/aibitsofts/public_html/aibitadmin.aibitsoft.cloud
     Application URL: aibitadmin.aibitsoft.cloud
     Application Startup File: dist/server.js
     Application Port: 4001
     ```

4. **Save and Start**
   - Click "Save" or "Create"
   - The application will start automatically
   - cPanel will handle the reverse proxy

5. **Test:**
   ```bash
   curl https://aibitadmin.aibitsoft.cloud/api/health
   ```

## Method 4: Test All APIs via Domain

Once the domain is configured, test all endpoints:

```bash
DOMAIN="https://aibitadmin.aibitsoft.cloud"

echo "=== Testing All APIs ==="
echo ""
echo "1. Health Check:"
curl -s "$DOMAIN/api/health" | jq .

echo ""
echo "2. Jobs API:"
curl -s "$DOMAIN/api/jobs" | jq '.success'

echo ""
echo "3. Templates API:"
curl -s "$DOMAIN/api/templates" | jq '.success'

echo ""
echo "4. Applications API:"
curl -s "$DOMAIN/api/applications" | jq '.success'

echo ""
echo "5. Blogs API:"
curl -s "$DOMAIN/api/blogs" | jq '.success'

echo ""
echo "6. Team Members API:"
curl -s "$DOMAIN/api/team-members" | jq '.success'

echo ""
echo "7. Zoom Meetings API:"
curl -s "$DOMAIN/api/zoom-meetings" | jq '.success'

echo ""
echo "8. User Resumes API:"
curl -s "$DOMAIN/api/user-resumes" | jq '.success'
```

## Method 5: Test via Postman

1. Open Postman
2. Create a new request
3. Set method to **GET**
4. Enter URL: `https://aibitadmin.aibitsoft.cloud/api/health`
5. Click **Send**
6. You should see the JSON response

## Method 6: Test via Browser Developer Tools

1. Open browser (Chrome/Firefox)
2. Press **F12** to open Developer Tools
3. Go to **Console** tab
4. Run this JavaScript:
   ```javascript
   fetch('https://aibitadmin.aibitsoft.cloud/api/health')
     .then(r => r.json())
     .then(data => console.log(data))
     .catch(err => console.error('Error:', err));
   ```

## Current Configuration

- **Application Port:** 4001
- **PM2 Process:** `aibitadmin-backend`
- **Status:** ✅ Running
- **Local Test:** ✅ Working (`http://localhost:4001/api/health`)
- **Domain:** `aibitadmin.aibitsoft.cloud`
- **Domain Test:** ⚠️ Needs cPanel Node.js Selector configuration

## Troubleshooting

### If domain returns "No input file specified" or 404:

**Solution:** Use cPanel Node.js Selector (Method 3 above)

### If domain returns connection timeout:

1. Check if app is running:
   ```bash
   pm2 status
   ```

2. Check if port 4001 is listening:
   ```bash
   netstat -tulpn | grep 4001
   ```

3. Verify local access works:
   ```bash
   curl http://localhost:4001/api/health
   ```

### If you get CORS errors:

The domain is already added to CORS allowed origins in `src/config/index.js`:
- `https://aibitadmin.aibitsoft.cloud`
- `http://aibitadmin.aibitsoft.cloud`

## Quick Test Commands

```bash
# Test health endpoint
curl https://aibitadmin.aibitsoft.cloud/api/health

# Test with verbose output (to see headers)
curl -v https://aibitadmin.aibitsoft.cloud/api/health

# Test and format JSON
curl -s https://aibitadmin.aibitsoft.cloud/api/health | jq .

# Test from server
curl http://localhost:4001/api/health
```

## Expected Response

When working correctly, you should get:

```json
{
  "status": "ok",
  "timestamp": "2026-03-06T11:15:58.210Z",
  "environment": "production"
}
```

---

**Note:** The `.htaccess` file has been updated with proxy rules, but for cPanel shared hosting, **Node.js Selector is the recommended method** as it handles everything automatically.
