Debugging patterns for Cloudflare Workers. Activates when troubleshooting errors, checking logs, or investigating production issues.
# All logs with pretty formatting
npx wrangler tail pitchey-api-prod --format pretty
# Errors only (most useful)
npx wrangler tail pitchey-api-prod --status error
# Filter by endpoint path
npx wrangler tail pitchey-api-prod --search "/api/browse"
npx wrangler tail pitchey-api-prod --search "/api/ndas"
npx wrangler tail pitchey-api-prod --search "/api/auth"
npx wrangler tail pitchey-api-prod --search "/api/pitches"
# Filter by HTTP method
npx wrangler tail pitchey-api-prod --method POST
npx wrangler tail pitchey-api-prod --method GET
# Combined filters
npx wrangler tail pitchey-api-prod --status error --search "/api/auth"
npx wrangler tail pitchey-api-prod --method POST --search "/api/ndas"
# Start dev server with remote bindings (connects to real DB/R2/KV)
npx wrangler dev --remote
# Press 'd' to open Chrome DevTools
# - Set breakpoints in Sources tab
# - Inspect variables in Scope panel
# - Profile memory usage
# - Check network requests
# Health check
curl https://pitchey-api-prod.ndlovucavelle.workers.dev/health
# GET with auth (copy session cookie from browser DevTools)
curl -X GET "https://pitchey-api-prod.ndlovucavelle.workers.dev/api/user" \
-H "Cookie: better-auth.session_token=YOUR_TOKEN"
# POST with JSON body
curl -X POST "https://pitchey-api-prod.ndlovucavelle.workers.dev/api/pitches" \
-H "Content-Type: application/json" \
-H "Cookie: better-auth.session_token=YOUR_TOKEN" \
-d '{"title": "Test Pitch", "description": "Testing"}'
# Test browse endpoints
curl "https://pitchey-api-prod.ndlovucavelle.workers.dev/api/browse?tab=trending&limit=4"
curl "https://pitchey-api-prod.ndlovucavelle.workers.dev/api/browse?tab=new&limit=4"
npx wrangler tail pitchey-api-prod --status error --format pretty
# Look for stack trace - shows exact file and line number
credentials: 'include' in frontend fetchcredentials: 'include'Access-Control-Allow-Credentials: truepostgres(env.HYPERDRIVE.connectionString)better-auth.session_token# 1. Check if Worker is responding
curl -I https://pitchey-api-prod.ndlovucavelle.workers.dev/health
# 2. Stream errors
npx wrangler tail pitchey-api-prod --status error --format pretty
# 3. Test specific endpoint
curl "https://pitchey-api-prod.ndlovucavelle.workers.dev/api/[endpoint]"
# 4. Check with auth if needed
# Get cookie from browser, test with curl
# 5. If still stuck, enable local debugging
npx wrangler dev --remote
# Press 'd' for DevTools