C11Advanced
CORS Understanding Training
30 minOnce (but the concept lasts a lifetime)
Format: Understand why browsers block certain requests.
Scenario:
Your frontend is at https://myapp.com, your API is at https://api.myapp.com. A user reports "request blocked." Why?
Core concept: Browsers have a "Same-Origin Policy" -- by default, they block requests from one website to another domain. This is a security measure to prevent malicious websites from stealing your bank account data.
Exercise: Determine whether the following requests will be blocked by CORS:
myapp.comrequestsapi.myapp.com-> ?myapp.comrequestsmyapp.com/api-> ?myapp.comrequestsgoogle.com/api-> ?- Server-side code requests any URL -> ?
Answer hint: Only browsers enforce CORS restrictions, servers do not. This is why API calls are typically proxied through the backend.