Skip to content
Back to skills

Cloudflare Debug

ASecurity

Debugging patterns for Cloudflare Workers. Activates when troubleshooting errors, checking logs, or investigating production issues.

  • 666 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added February 8, 2026
code-qualitybashtestingdebuggingapidatabasefrontend

Works with

  • api

Security analysis

A96/100
  • mediumUses curl or wget to download content

Pro shows the line behind each finding and how to fix it

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill cloudflare-debug --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cloudflare Debug?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cloudflare Debug
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-cloudflare-debug/badge)](https://www.skillsdirectory.com/skills/majiayu000-cloudflare-debug)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cloudflare-debug
description: Debugging patterns for Cloudflare Workers. Activates when troubleshooting errors, checking logs, or investigating production issues.
triggers:
  - debug
  - error
  - logs
  - tail
  - console
  - 500
  - 404
  - exception
  - troubleshoot
  - fix
  - broken
  - not working
---

# Cloudflare Workers Debugging

## Real-Time Log Commands

```bash
# 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"
```

## Local Debugging with Breakpoints

```bash
# 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
```

## Test Endpoints Directly

```bash
# 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"
```

## Common Error Patterns

### ReferenceError: X is not defined
- Check imports at top of file
- Verify variable is in scope where used
- Check if variable was renamed but not updated everywhere
- Look for typos in variable names

### TypeError: Cannot read property 'X' of undefined
- Add null checks before accessing properties
- Verify API response shape matches expectations
- Check if async data loaded before access

### 500 Internal Server Error
```bash
npx wrangler tail pitchey-api-prod --status error --format pretty
# Look for stack trace - shows exact file and line number
```

### 401 Unauthorized
- Better Auth uses cookies, NOT JWT headers
- Ensure `credentials: 'include'` in frontend fetch
- Check session hasn't expired
- Verify cookie domain matches

### 404 Not Found
- Check route is registered in Worker
- Verify HTTP method matches (GET vs POST)
- Check for typos in endpoint path

### CORS Errors
- Frontend must use `credentials: 'include'`
- Worker must return `Access-Control-Allow-Credentials: true`
- Origin must match exactly (including https://)

### Database Connection Errors
- Always use: `postgres(env.HYPERDRIVE.connectionString)`
- Never use direct Neon URL or pooler URL with Hyperdrive
- Check Neon dashboard for connection limit issues

### Session/Auth Errors (Better Auth)
- Uses cookies, NOT Authorization header
- Session cookie name: `better-auth.session_token`
- Must include credentials in fetch calls
- Check cookie SameSite and Secure attributes

## Quick Diagnostic Sequence

```bash
# 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
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.