This is the actually working solution for proxying Antigravity's API calls.
The Node.js proxy cannot inspect HTTPS content without implementing full MITM with certificate generation.
mitmproxy is the industry-standard tool that handles all of this automatically.
brew install mitmproxy# Install python-dotenv for reading .env file
pip3 install python-dotenvmitmproxy --versionShould output something like: Mitmproxy: 10.x.x
This is the critical step that allows mitmproxy to intercept HTTPS traffic.
# Start mitmproxy once to generate certificate
mitmproxyPress q to quit.
The certificate is now at: ~/.mitmproxy/mitmproxy-ca-cert.pem
# Open certificate in Keychain Access
open ~/.mitmproxy/mitmproxy-ca-cert.pemIn Keychain Access:
- Find "mitmproxy" certificate
- Double-click it
- Expand "Trust" section
- Set "When using this certificate" to "Always Trust"
- Close (you'll be prompted for password)
Visual Guide:
- Certificate should show "This certificate is marked as trusted for all users"
- Green checkmark next to "mitmproxy"
cd ~/dev/personal/antigravity-proxy
# Use the Python addon
mitmproxy -s mitmproxy-addon.py --listen-port 8080You should see:
🚀 Antigravity Proxy - MITM Interceptor
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔑 Using API Key: AIzaSyABC123***
🎯 Target: generativelanguage.googleapis.com
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Proxy server listening at http://*:8080
In a new terminal:
cd ~/dev/personal/antigravity-proxy
# Use the shell script
./scripts/launch-antigravity.shOr manually:
HTTP_PROXY=http://localhost:8080 \
HTTPS_PROXY=http://localhost:8080 \
/Applications/Antigravity.app/Contents/MacOS/AntigravityWhen you use Antigravity's AI features, you should see in the mitmproxy terminal:
📥 INCOMING REQUEST #1
Method: POST
URL: https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent
🔄 Replaced key in header
Old: AIzaSyABC123***
New: AIzaSyDEF456***
✅ RESPONSE
Status: 200
📊 Stats: 1 requests, 1 keys replaced
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The addon reads from your .env file:
# Make sure you have this set
GEMINI_API_KEY=your_actual_api_key_hereSymptom: Antigravity shows SSL errors
Solution:
- Open Keychain Access
- Search for "mitmproxy"
- Double-click certificate
- Set Trust to "Always Trust"
- Restart Antigravity
Symptom: mitmproxy shows no traffic
Solutions:
-
Verify proxy settings:
# In the terminal where you launched Antigravity echo $HTTP_PROXY echo $HTTPS_PROXY
Should both output:
http://localhost:8080 -
Check if mitmproxy is running:
lsof -ti:8080
Should return a process ID
-
Test with curl:
HTTP_PROXY=http://localhost:8080 \ HTTPS_PROXY=http://localhost:8080 \ curl https://generativelanguage.googleapis.com/v1beta/models
Should appear in mitmproxy logs
Solution:
brew install mitmproxySolution:
pip3 install python-dotenvmitmproxy has an interactive TUI:
mitmproxy -s mitmproxy-addon.pyPress:
q- Quit?- Help- Arrow keys - Navigate requests
- Enter - View request/response details
mitm has a web interface:
mitmweb -s mitmproxy-addon.py --listen-port 8080Then open: http://localhost:8081
For background operation:
mitmdump -s mitmproxy-addon.py --listen-port 8080Record all traffic to a file:
mitmdump -s mitmproxy-addon.py --listen-port 8080 -w traffic.mitmReplay later:
mitmproxy -r traffic.mitm| Feature | Node.js Proxy | mitmproxy |
|---|---|---|
| HTTPS Inspection | ❌ Doesn't work | ✅ Works perfectly |
| Certificate Setup | ❌ Complex | ✅ Automatic |
| API Key Replacement | ❌ Can't access content | ✅ Full access |
| Logging | ✅ Good | ✅ Excellent |
| Setup Time | 5 minutes | 10 minutes |
| Actually Works | ❌ No | ✅ Yes |
Add to ~/.zshrc or ~/.bashrc:
# Antigravity with proxy
antigravity-proxy() {
# Start mitmproxy in background
mitmdump -s ~/dev/personal/antigravity-proxy/mitmproxy-addon.py --listen-port 8080 > /dev/null 2>&1 &
MITM_PID=$!
# Wait for proxy to start
sleep 2
# Launch Antigravity
HTTP_PROXY=http://localhost:8080 \
HTTPS_PROXY=http://localhost:8080 \
/Applications/Antigravity.app/Contents/MacOS/Antigravity
# Kill mitmproxy when Antigravity exits
kill $MITM_PID 2>/dev/null
}Then just run:
antigravity-proxyRun mitmproxy as a service:
# Install pm2
npm install -g pm2
# Create start script
cat > ~/dev/personal/antigravity-proxy/start-mitm.sh << 'EOF'
#!/bin/bash
cd ~/dev/personal/antigravity-proxy
mitmdump -s mitmproxy-addon.py --listen-port 8080
EOF
chmod +x ~/dev/personal/antigravity-proxy/start-mitm.sh
# Start with pm2
pm2 start ~/dev/personal/antigravity-proxy/start-mitm.sh --name antigravity-proxy
# Make it start on boot
pm2 save
pm2 startupThen always launch Antigravity with proxy settings:
alias antigravity='HTTP_PROXY=http://localhost:8080 HTTPS_PROXY=http://localhost:8080 /Applications/Antigravity.app/Contents/MacOS/Antigravity'⚠️ The mitmproxy certificate allows intercepting ALL HTTPS traffic- Only use on your development machine
- Don't export the private key (
~/.mitmproxy/mitmproxy-ca.pem) - Revoke trust when done with development
This is the working solution. The Node.js proxy was a good learning exercise but doesn't actually work for HTTPS content inspection.
mitmproxy:
- ✅ Industry standard for API interception
- ✅ Handles certificate generation automatically
- ✅ Can inspect and modify HTTPS traffic
- ✅ Well-documented and maintained
- ✅ Actually works with Antigravity
Total setup time: ~15 minutes