HTTP Status Code
رمز حالة HTTP
Definition
Numeric codes returned by a server indicating whether an HTTP request succeeded or why it failed.
رموز رقمية تُعيدها الخادم تشير إلى ما إذا كان طلب HTTP قد نجح أو سبب فشله.
Why It Matters
On 404Fault, verifyAdminRequest() returning 401 vs 403 matters — 401 means unauthenticated, 403 means authenticated but not admin. Client-side code checks `if (!res.ok)` which catches any non-2xx code.
في 404Fault، إعادة verifyAdminRequest() للـ401 مقابل 403 مهمة — 401 تعني غير مصادق عليه، 403 تعني مصادق عليه لكن ليس مديرًا. الكود من جانب العميل يتحقق من `if (!res.ok)`.
Full Definition
Example Usage
“return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); // vs return NextResponse.json({ error: 'Admin required' }, { status: 403 });”
“return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); // مقابل return NextResponse.json({ error: 'Admin required' }, { status: 403 });”
AI Builder Tips
Avoid these mistakes when using HTTP Status Code:
Returning 200 with `{ error: '...' }` in the body — use the proper status code
Confusing 401 (not logged in) and 403 (logged in but not permitted)
Sign in to unlock guided AI explanations from AI Teacher.
Generate a Prompt
Copy this prompt and use it directly with any AI model — no setup needed.
Help me build a project using HTTP Status Code.
Explain:
1. What is HTTP Status Code and why it matters
2. The core architecture and required tools
3. Step-by-step implementation plan
4. Common mistakes to avoid: Returning 200 with `{ error: '...' }` in the body — use the proper status code, Confusing 401 (not logged in) and 403 (logged in but not permitted)
5. Best practices and production tips