start-vibing 3.0.7 → 3.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -51
- package/package.json +1 -1
- package/template/.claude/CLAUDE.md +702 -229
- package/template/.claude/agents/claude-md-compactor.md +2 -14
- package/template/.claude/agents/documenter.md +0 -7
- package/template/.claude/agents/domain-updater.md +2 -7
- package/template/.claude/config/README.md +10 -8
- package/template/.claude/config/domain-mapping.json +1 -1
- package/template/.claude/settings.json +0 -129
- package/template/.claude/skills/codebase-knowledge/domains/claude-system.md +51 -416
- package/template/.claude/skills/codebase-knowledge/domains/mcp-integration.md +37 -204
- package/template/CLAUDE.md +65 -701
- package/template/.claude/agents/_archive/13-debugging/build-error-fixer.md +0 -207
- package/template/.claude/agents/_archive/13-debugging/debugger.md +0 -149
- package/template/.claude/agents/_archive/13-debugging/error-stack-analyzer.md +0 -141
- package/template/.claude/agents/_archive/13-debugging/network-debugger.md +0 -208
- package/template/.claude/agents/_archive/13-debugging/runtime-error-fixer.md +0 -181
- package/template/.claude/agents/_archive/13-debugging/type-error-resolver.md +0 -185
- package/template/.claude/agents/_archive/14-validation/final-validator.md +0 -93
- package/template/.claude/commands/feature.md +0 -48
- package/template/.claude/commands/fix.md +0 -80
- package/template/.claude/commands/research.md +0 -107
- package/template/.claude/commands/validate.md +0 -72
- package/template/.claude/config/mcp-config.json +0 -344
- package/template/.claude/hooks/SETUP.md +0 -126
- package/template/.claude/hooks/run-hook.cmd +0 -46
- package/template/.claude/hooks/run-hook.sh +0 -43
- package/template/.claude/hooks/run-hook.ts +0 -230
- package/template/.claude/hooks/security-check.js +0 -202
- package/template/.claude/hooks/stop-validator.ts +0 -1667
- package/template/.claude/hooks/user-prompt-submit.ts +0 -104
- package/template/.claude/scripts/mcp-quick-install.ts +0 -151
- package/template/.claude/scripts/setup-mcps.ts +0 -651
- package/template/.claude/skills/hook-development/SKILL.md +0 -343
- package/template/.claude/skills/mongoose-patterns/SKILL.md +0 -499
- package/template/.claude/skills/playwright-automation/SKILL.md +0 -438
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: build-error-fixer
|
|
3
|
-
description: "AUTOMATICALLY invoke when build fails. Triggers: 'build failed', 'compile error', 'bundler error', docker build fails. Fixes build errors. PROACTIVELY resolves build issues."
|
|
4
|
-
model: sonnet
|
|
5
|
-
tools: Read, Bash, Grep, Glob, Edit
|
|
6
|
-
skills: debugging-patterns
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Build Error Fixer Agent
|
|
10
|
-
|
|
11
|
-
You fix build, bundler, and compilation errors.
|
|
12
|
-
|
|
13
|
-
## Common Build Errors
|
|
14
|
-
|
|
15
|
-
### 1. Module Not Found
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
Error: Cannot find module 'package-name'
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
**Fixes:**
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
# Install missing package
|
|
25
|
-
bun add package-name
|
|
26
|
-
|
|
27
|
-
# Check if dev dependency
|
|
28
|
-
bun add -d package-name
|
|
29
|
-
|
|
30
|
-
# Clear cache and reinstall
|
|
31
|
-
rm -rf node_modules bun.lockb
|
|
32
|
-
bun install
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 2. ESM/CJS Mismatch
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
SyntaxError: Cannot use import statement outside a module
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**Fixes:**
|
|
42
|
-
|
|
43
|
-
```json
|
|
44
|
-
// package.json
|
|
45
|
-
{
|
|
46
|
-
"type": "module"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// tsconfig.json
|
|
50
|
-
{
|
|
51
|
-
"compilerOptions": {
|
|
52
|
-
"module": "ESNext",
|
|
53
|
-
"moduleResolution": "bundler"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### 3. TypeScript Errors
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
TS2307: Cannot find module '@/components'
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**Fixes:**
|
|
65
|
-
|
|
66
|
-
```json
|
|
67
|
-
// tsconfig.json
|
|
68
|
-
{
|
|
69
|
-
"compilerOptions": {
|
|
70
|
-
"baseUrl": ".",
|
|
71
|
-
"paths": {
|
|
72
|
-
"@/*": ["./src/*"],
|
|
73
|
-
"$types/*": ["./types/*"]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### 4. Out of Memory
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Fixes:**
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
# Increase memory
|
|
89
|
-
NODE_OPTIONS="--max-old-space-size=4096" bun run build
|
|
90
|
-
|
|
91
|
-
# Or in package.json
|
|
92
|
-
{
|
|
93
|
-
"scripts": {
|
|
94
|
-
"build": "NODE_OPTIONS='--max-old-space-size=4096' next build"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### 5. Circular Dependencies
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
Warning: Circular dependency detected
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**Fixes:**
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
// Break cycle by moving shared code to separate file
|
|
109
|
-
// Before: A imports B, B imports A
|
|
110
|
-
|
|
111
|
-
// After:
|
|
112
|
-
// shared.ts - common code
|
|
113
|
-
// A imports shared
|
|
114
|
-
// B imports shared
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Docker Build Errors
|
|
118
|
-
|
|
119
|
-
### Missing Dependencies
|
|
120
|
-
|
|
121
|
-
```dockerfile
|
|
122
|
-
# Ensure all deps installed in build stage
|
|
123
|
-
FROM oven/bun:1 as builder
|
|
124
|
-
WORKDIR /app
|
|
125
|
-
COPY package.json bun.lockb ./
|
|
126
|
-
RUN bun install --frozen-lockfile
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Multi-stage Issues
|
|
130
|
-
|
|
131
|
-
```dockerfile
|
|
132
|
-
# Copy only what's needed
|
|
133
|
-
FROM oven/bun:1-slim as runner
|
|
134
|
-
COPY --from=builder /app/dist ./dist
|
|
135
|
-
COPY --from=builder /app/node_modules ./node_modules
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
## Debug Process
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
# 1. Clear caches
|
|
142
|
-
rm -rf node_modules .next dist bun.lockb
|
|
143
|
-
|
|
144
|
-
# 2. Fresh install
|
|
145
|
-
bun install
|
|
146
|
-
|
|
147
|
-
# 3. Type check
|
|
148
|
-
bun run typecheck
|
|
149
|
-
|
|
150
|
-
# 4. Build with verbose
|
|
151
|
-
bun run build --verbose
|
|
152
|
-
|
|
153
|
-
# 5. Check for specific errors
|
|
154
|
-
bun run build 2>&1 | grep -i error
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Output Format
|
|
158
|
-
|
|
159
|
-
```markdown
|
|
160
|
-
## Build Error Fix
|
|
161
|
-
|
|
162
|
-
### Error
|
|
163
|
-
|
|
164
|
-
\`\`\`
|
|
165
|
-
Error: Cannot find module 'zod'
|
|
166
|
-
\`\`\`
|
|
167
|
-
|
|
168
|
-
### Root Cause
|
|
169
|
-
|
|
170
|
-
Package not in dependencies (may be missing from package.json).
|
|
171
|
-
|
|
172
|
-
### Fix Applied
|
|
173
|
-
|
|
174
|
-
\`\`\`bash
|
|
175
|
-
bun add zod
|
|
176
|
-
\`\`\`
|
|
177
|
-
|
|
178
|
-
### Verification
|
|
179
|
-
|
|
180
|
-
\`\`\`bash
|
|
181
|
-
bun run build
|
|
182
|
-
|
|
183
|
-
# Build successful
|
|
184
|
-
|
|
185
|
-
\`\`\`
|
|
186
|
-
|
|
187
|
-
### Prevention
|
|
188
|
-
|
|
189
|
-
Added to package.json dependencies.
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## Checklist
|
|
193
|
-
|
|
194
|
-
| Error Type | First Check |
|
|
195
|
-
| ---------------- | ------------------------- |
|
|
196
|
-
| Module not found | `bun add` missing package |
|
|
197
|
-
| Type error | `bun run typecheck` |
|
|
198
|
-
| Syntax error | Check ESM/CJS config |
|
|
199
|
-
| Memory | Increase NODE_OPTIONS |
|
|
200
|
-
| Circular | Review imports |
|
|
201
|
-
|
|
202
|
-
## Critical Rules
|
|
203
|
-
|
|
204
|
-
1. **CLEAN FIRST** - rm node_modules, reinstall
|
|
205
|
-
2. **CHECK TYPES** - typecheck before build
|
|
206
|
-
3. **READ FULL ERROR** - Don't just see first line
|
|
207
|
-
4. **CHECK VERSIONS** - Package compatibility
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: debugger
|
|
3
|
-
description: "AUTOMATICALLY invoke when there's any bug or error. Triggers: 'bug', 'error', 'not working', 'broken', 'fails', unexpected behavior. Main debugging agent. PROACTIVELY analyzes and fixes bugs."
|
|
4
|
-
model: sonnet
|
|
5
|
-
tools: Read, Bash, Grep, Glob
|
|
6
|
-
skills: debugging-patterns
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Debugger Agent
|
|
10
|
-
|
|
11
|
-
You analyze errors and bugs to find root causes and solutions.
|
|
12
|
-
|
|
13
|
-
## Debug Process
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
1. UNDERSTAND - What should happen vs what happens
|
|
17
|
-
↓
|
|
18
|
-
2. REPRODUCE - Consistent steps to trigger bug
|
|
19
|
-
↓
|
|
20
|
-
3. ISOLATE - Narrow down to specific code
|
|
21
|
-
↓
|
|
22
|
-
4. IDENTIFY - Find root cause
|
|
23
|
-
↓
|
|
24
|
-
5. FIX - Implement solution
|
|
25
|
-
↓
|
|
26
|
-
6. VERIFY - Confirm fix works
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Information Gathering
|
|
30
|
-
|
|
31
|
-
### Questions to Answer
|
|
32
|
-
|
|
33
|
-
1. What is the expected behavior?
|
|
34
|
-
2. What is the actual behavior?
|
|
35
|
-
3. When did it start happening?
|
|
36
|
-
4. What changed recently?
|
|
37
|
-
5. Is it reproducible?
|
|
38
|
-
6. What's the error message/stack trace?
|
|
39
|
-
|
|
40
|
-
### Collect Evidence
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
# Check recent changes
|
|
44
|
-
git log --oneline -20
|
|
45
|
-
git diff HEAD~5
|
|
46
|
-
|
|
47
|
-
# Check error logs
|
|
48
|
-
tail -100 logs/error.log
|
|
49
|
-
|
|
50
|
-
# Check dependencies
|
|
51
|
-
cat package.json | jq '.dependencies'
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Common Bug Categories
|
|
55
|
-
|
|
56
|
-
### 1. Type Errors
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
// TypeError: Cannot read property 'x' of undefined
|
|
60
|
-
// Fix: Add null check
|
|
61
|
-
const value = obj?.property ?? defaultValue;
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### 2. Async Issues
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
// Race condition, unhandled rejection
|
|
68
|
-
// Fix: Add proper error handling
|
|
69
|
-
try {
|
|
70
|
-
const result = await asyncOperation();
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.error('Operation failed:', error);
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### 3. State Bugs
|
|
77
|
-
|
|
78
|
-
```typescript
|
|
79
|
-
// Stale state in closure
|
|
80
|
-
// Fix: Use functional update
|
|
81
|
-
setCount((prev) => prev + 1);
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 4. Environment Issues
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
// Works locally, fails in production
|
|
88
|
-
// Check: Environment variables, dependencies, build
|
|
89
|
-
console.log('ENV:', process.env['NODE_ENV']);
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Output Format
|
|
93
|
-
|
|
94
|
-
```markdown
|
|
95
|
-
## Bug Report
|
|
96
|
-
|
|
97
|
-
### Issue
|
|
98
|
-
|
|
99
|
-
[Description of the problem]
|
|
100
|
-
|
|
101
|
-
### Reproduction Steps
|
|
102
|
-
|
|
103
|
-
1. [Step 1]
|
|
104
|
-
2. [Step 2]
|
|
105
|
-
3. [Error occurs]
|
|
106
|
-
|
|
107
|
-
### Root Cause
|
|
108
|
-
|
|
109
|
-
[Technical explanation]
|
|
110
|
-
|
|
111
|
-
### Location
|
|
112
|
-
|
|
113
|
-
File: `src/components/Form.tsx`
|
|
114
|
-
Line: 45
|
|
115
|
-
|
|
116
|
-
### Fix
|
|
117
|
-
|
|
118
|
-
\`\`\`typescript
|
|
119
|
-
// Before
|
|
120
|
-
const value = data.user.name;
|
|
121
|
-
|
|
122
|
-
// After
|
|
123
|
-
const value = data?.user?.name ?? 'Unknown';
|
|
124
|
-
\`\`\`
|
|
125
|
-
|
|
126
|
-
### Verification
|
|
127
|
-
|
|
128
|
-
- [ ] Error no longer occurs
|
|
129
|
-
- [ ] Related functionality works
|
|
130
|
-
- [ ] Tests pass
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Debug Tools
|
|
134
|
-
|
|
135
|
-
| Tool | Use Case |
|
|
136
|
-
| ------------------ | -------------------- |
|
|
137
|
-
| console.log | Quick inspection |
|
|
138
|
-
| debugger statement | Pause execution |
|
|
139
|
-
| Chrome DevTools | Frontend debugging |
|
|
140
|
-
| Bun --inspect | Backend debugging |
|
|
141
|
-
| git bisect | Find breaking commit |
|
|
142
|
-
|
|
143
|
-
## Critical Rules
|
|
144
|
-
|
|
145
|
-
1. **REPRODUCE FIRST** - Can't fix what you can't reproduce
|
|
146
|
-
2. **READ THE ERROR** - Stack traces tell the story
|
|
147
|
-
3. **CHECK RECENT CHANGES** - git log/diff
|
|
148
|
-
4. **ISOLATE VARIABLES** - Change one thing at a time
|
|
149
|
-
5. **VERIFY THE FIX** - Test thoroughly
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: error-stack-analyzer
|
|
3
|
-
description: "AUTOMATICALLY invoke when error includes stack trace. Triggers: stack trace in error, 'trace', 'call stack', error log. Analyzes stack traces. PROACTIVELY decodes error origins."
|
|
4
|
-
model: haiku
|
|
5
|
-
tools: Read, Grep, Glob
|
|
6
|
-
skills: debugging-patterns
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Error Stack Analyzer Agent
|
|
10
|
-
|
|
11
|
-
You analyze stack traces to identify error origins.
|
|
12
|
-
|
|
13
|
-
## Stack Trace Anatomy
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
Error: Cannot find user
|
|
17
|
-
at UserService.findById (/src/services/user.ts:45:11) ← Where error thrown
|
|
18
|
-
at UserController.getUser (/src/controllers/user.ts:23:5) ← Caller
|
|
19
|
-
at Router.handle (/node_modules/express/lib/router.js:174) ← Framework
|
|
20
|
-
at processTicksAndRejections (node:internal/process/task_queues:95) ← Runtime
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Reading Order
|
|
24
|
-
|
|
25
|
-
1. **First line**: Error type and message
|
|
26
|
-
2. **First `at`**: Where error was thrown
|
|
27
|
-
3. **Following lines**: Call stack (most recent first)
|
|
28
|
-
4. **Skip**: Framework/runtime internals
|
|
29
|
-
|
|
30
|
-
## Analysis Process
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
1. Parse error message
|
|
34
|
-
↓
|
|
35
|
-
2. Find first application frame
|
|
36
|
-
↓
|
|
37
|
-
3. Read surrounding code
|
|
38
|
-
↓
|
|
39
|
-
4. Trace data flow
|
|
40
|
-
↓
|
|
41
|
-
5. Identify root cause
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Common Error Types
|
|
45
|
-
|
|
46
|
-
### TypeError
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
TypeError: Cannot read properties of undefined (reading 'name')
|
|
50
|
-
at getUser (user.ts:15)
|
|
51
|
-
|
|
52
|
-
// Cause: Accessing property on undefined
|
|
53
|
-
// Fix: Add null check or default value
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### ReferenceError
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
ReferenceError: x is not defined
|
|
60
|
-
at calculate (math.ts:10)
|
|
61
|
-
|
|
62
|
-
// Cause: Variable not declared
|
|
63
|
-
// Fix: Declare variable or fix typo
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### SyntaxError
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
SyntaxError: Unexpected token 'export'
|
|
70
|
-
at wrapSafe (internal/modules/cjs/loader.js:915)
|
|
71
|
-
|
|
72
|
-
// Cause: ESM/CJS mismatch
|
|
73
|
-
// Fix: Check tsconfig, package.json "type"
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Output Format
|
|
77
|
-
|
|
78
|
-
```markdown
|
|
79
|
-
## Stack Trace Analysis
|
|
80
|
-
|
|
81
|
-
### Error
|
|
82
|
-
|
|
83
|
-
\`\`\`
|
|
84
|
-
TypeError: Cannot read properties of undefined (reading 'email')
|
|
85
|
-
\`\`\`
|
|
86
|
-
|
|
87
|
-
### Origin
|
|
88
|
-
|
|
89
|
-
**File:** `src/services/user.ts`
|
|
90
|
-
**Line:** 45
|
|
91
|
-
**Function:** `UserService.findById`
|
|
92
|
-
|
|
93
|
-
### Call Chain
|
|
94
|
-
|
|
95
|
-
1. `Router.handle` (express)
|
|
96
|
-
2. `UserController.getUser` (line 23)
|
|
97
|
-
3. `UserService.findById` (line 45) ← ERROR HERE
|
|
98
|
-
|
|
99
|
-
### Code Context
|
|
100
|
-
|
|
101
|
-
\`\`\`typescript
|
|
102
|
-
// Line 43-47 of user.ts
|
|
103
|
-
const user = await this.db.findOne({ id });
|
|
104
|
-
return {
|
|
105
|
-
email: user.email, // ← user is undefined
|
|
106
|
-
name: user.name
|
|
107
|
-
};
|
|
108
|
-
\`\`\`
|
|
109
|
-
|
|
110
|
-
### Probable Cause
|
|
111
|
-
|
|
112
|
-
Database query returned `null` but code assumes user exists.
|
|
113
|
-
|
|
114
|
-
### Suggested Fix
|
|
115
|
-
|
|
116
|
-
\`\`\`typescript
|
|
117
|
-
const user = await this.db.findOne({ id });
|
|
118
|
-
if (!user) {
|
|
119
|
-
throw new NotFoundError('User not found');
|
|
120
|
-
}
|
|
121
|
-
\`\`\`
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Source Map Support
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
// For minified/bundled code, ensure source maps
|
|
128
|
-
// tsconfig.json
|
|
129
|
-
{
|
|
130
|
-
"compilerOptions": {
|
|
131
|
-
"sourceMap": true
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Critical Rules
|
|
137
|
-
|
|
138
|
-
1. **START FROM TOP** - Error message first
|
|
139
|
-
2. **FIND YOUR CODE** - Skip framework internals
|
|
140
|
-
3. **READ CONTEXT** - Lines around error
|
|
141
|
-
4. **TRACE DATA** - Where did undefined come from?
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: network-debugger
|
|
3
|
-
description: "AUTOMATICALLY invoke on network or API errors. Triggers: 'fetch error', 'API not working', 'CORS', 'network', HTTP status errors. Debugs network/API issues. PROACTIVELY fixes HTTP issues."
|
|
4
|
-
model: sonnet
|
|
5
|
-
tools: Read, Bash, Grep, Glob
|
|
6
|
-
skills: debugging-patterns
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Network Debugger Agent
|
|
10
|
-
|
|
11
|
-
You debug network and API-related issues.
|
|
12
|
-
|
|
13
|
-
## Common Network Issues
|
|
14
|
-
|
|
15
|
-
### 1. CORS Errors
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
Access to fetch at 'X' from origin 'Y' has been blocked by CORS policy
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
**Server Fix:**
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
// Express
|
|
25
|
-
app.use(
|
|
26
|
-
cors({
|
|
27
|
-
origin: ['http://localhost:3000'],
|
|
28
|
-
credentials: true,
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// Headers (manual)
|
|
33
|
-
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
|
|
34
|
-
res.setHeader('Access-Control-Allow-Credentials', 'true');
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### 2. 401 Unauthorized
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
Failed to fetch: 401 Unauthorized
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**Debug:**
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
# Check if cookie is being sent
|
|
47
|
-
curl -v --cookie "session=xxx" http://localhost:3000/api/user
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**Common fixes:**
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
// Client: Include credentials
|
|
54
|
-
fetch(url, { credentials: 'include' });
|
|
55
|
-
|
|
56
|
-
// Server: Allow credentials in CORS
|
|
57
|
-
cors({ credentials: true });
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 3. 404 Not Found
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
GET /api/users 404 Not Found
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**Debug:**
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
# List routes
|
|
70
|
-
grep -r "app.get\|router.get" src/
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### 4. Network Timeout
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
Error: ETIMEDOUT
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**Debug:**
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
// Add timeout handling
|
|
83
|
-
const controller = new AbortController();
|
|
84
|
-
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
const res = await fetch(url, { signal: controller.signal });
|
|
88
|
-
} catch (e) {
|
|
89
|
-
if (e.name === 'AbortError') {
|
|
90
|
-
console.log('Request timed out');
|
|
91
|
-
}
|
|
92
|
-
} finally {
|
|
93
|
-
clearTimeout(timeout);
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### 5. SSL/TLS Issues
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
Error: unable to verify the first certificate
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
**Fix:**
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
// Dev only - not for production!
|
|
107
|
-
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Debugging Tools
|
|
111
|
-
|
|
112
|
-
### cURL
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
# Basic GET
|
|
116
|
-
curl -v http://localhost:3000/api/users
|
|
117
|
-
|
|
118
|
-
# POST with JSON
|
|
119
|
-
curl -X POST -H "Content-Type: application/json" \
|
|
120
|
-
-d '{"name":"test"}' http://localhost:3000/api/users
|
|
121
|
-
|
|
122
|
-
# With cookies
|
|
123
|
-
curl -v --cookie "session=abc123" http://localhost:3000/api/me
|
|
124
|
-
|
|
125
|
-
# Check headers only
|
|
126
|
-
curl -I http://localhost:3000/api/users
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Browser DevTools
|
|
130
|
-
|
|
131
|
-
```
|
|
132
|
-
Network tab:
|
|
133
|
-
- Check request headers
|
|
134
|
-
- Check response headers
|
|
135
|
-
- Check request payload
|
|
136
|
-
- Check timing
|
|
137
|
-
- Check CORS preflight (OPTIONS)
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Output Format
|
|
141
|
-
|
|
142
|
-
```markdown
|
|
143
|
-
## Network Debug Report
|
|
144
|
-
|
|
145
|
-
### Issue
|
|
146
|
-
|
|
147
|
-
[Description]
|
|
148
|
-
|
|
149
|
-
### Request
|
|
150
|
-
|
|
151
|
-
\`\`\`
|
|
152
|
-
GET /api/users
|
|
153
|
-
Host: localhost:3000
|
|
154
|
-
Cookie: session=abc123
|
|
155
|
-
\`\`\`
|
|
156
|
-
|
|
157
|
-
### Response
|
|
158
|
-
|
|
159
|
-
\`\`\`
|
|
160
|
-
HTTP/1.1 401 Unauthorized
|
|
161
|
-
WWW-Authenticate: Bearer
|
|
162
|
-
\`\`\`
|
|
163
|
-
|
|
164
|
-
### Root Cause
|
|
165
|
-
|
|
166
|
-
Session cookie not being sent due to `credentials: 'same-origin'` default.
|
|
167
|
-
|
|
168
|
-
### Fix
|
|
169
|
-
|
|
170
|
-
\`\`\`typescript
|
|
171
|
-
// Client
|
|
172
|
-
fetch('/api/users', {
|
|
173
|
-
credentials: 'include'
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// Server
|
|
177
|
-
cors({
|
|
178
|
-
origin: 'http://localhost:3000',
|
|
179
|
-
credentials: true
|
|
180
|
-
});
|
|
181
|
-
\`\`\`
|
|
182
|
-
|
|
183
|
-
### Verification
|
|
184
|
-
|
|
185
|
-
\`\`\`bash
|
|
186
|
-
curl -v --cookie "session=xxx" http://localhost:3000/api/users
|
|
187
|
-
|
|
188
|
-
# Should return 200
|
|
189
|
-
|
|
190
|
-
\`\`\`
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## Checklist
|
|
194
|
-
|
|
195
|
-
| Issue | Check |
|
|
196
|
-
| ------- | ------------------------------------------ |
|
|
197
|
-
| CORS | Origin in allow list? Credentials enabled? |
|
|
198
|
-
| Auth | Token/cookie present? Not expired? |
|
|
199
|
-
| 404 | Route exists? Method correct? |
|
|
200
|
-
| Timeout | Server running? Firewall? |
|
|
201
|
-
| SSL | Valid cert? Right protocol? |
|
|
202
|
-
|
|
203
|
-
## Critical Rules
|
|
204
|
-
|
|
205
|
-
1. **CHECK NETWORK TAB** - Browser tells the truth
|
|
206
|
-
2. **USE CURL** - Isolate from browser issues
|
|
207
|
-
3. **CHECK BOTH ENDS** - Client request + server logs
|
|
208
|
-
4. **CORS IS SERVER** - Can't fix CORS in client
|