انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-024-L06

عرض عملي: مشاهدة فشل CORS وإصلاحه

  • الدرس 6 من 6
  • Junior
في هذا الدرس 3 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

see the browser error and fix it for one origin. Prepares JNR-024-LAB1.

تفاصيل المخطط المبدئي

خطوة بخطوة

  1. Run Shop API on port 8080 and serve a small HTML page from another port (for example 3000) that calls fetch("http://localhost:8080/products").
  2. Open the browser console and read the CORS error; check in the network tab that the server still answered.
  3. Configure CORS for exactly http://localhost:3000 and restart.
  4. Planned mistake: use allowedOrigins("*") together with credentials. Fix: list the explicit origin; the wildcard with credentials is not allowed and is unsafe.
  5. Reload the page and see the call succeed; try from another origin (port 3001) and see it still fail.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.