Skip to content
Ameen Abozaid
Planned lessonJNR-024-L06

Demo: watching CORS fail and fixing it

  • Lesson 6 of 6
  • Junior
On This Lesson 3 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

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

Draft outline details

Step by step

  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.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.