Episode 02 game · Raiden · Lightning
Raiden’s Gate
Your app on localhost:3000 calls an API on another origin. Set the server’s response headers so four requests get through the browser’s gate, without opening it to everyone.
RaidenYour app is on localhost:3000 and the API lives on another origin. Set the server’s headers, then send the request through my gate.
02Seal 02
Your app
http://localhost:3000Raiden checks CORSAPI server
api.shopkart.devRequest 1 of 4
Load the product list
Blocked by the gate 0
What the server sends back with each response:
New seal earned
Gate mastered
Acharya’s Rule #2If it works in Postman, the API isn’t broken. Your server hasn’t answered the browser’s question.
Postman is a courier
It sends the request and shows the reply. It never checks CORS.
The browser is a gatekeeper
Your code may only read a cross-origin reply if the server says so.
The fix lives on the server
Headers like Access-Control-Allow-Origin. 'no-cors' just hides the data.