Exercise 1: Why This Course Never Needed CORS — Possible Solution ==================================================================== WHY CORS EXISTS IN THE FIRST PLACE ------------------------------ CORS configuration is needed whenever a frontend running at one origin needs to make requests to a backend running at a different origin - the browser blocks cross-origin requests by default unless the server explicitly grants permission. WHY THIS COURSE NEVER FACED THAT SITUATION ------------------------------ Chapter 1 mounted the frontend directly on the same FastAPI app via StaticFiles(directory="static", html=True) - the vanilla-JS frontend and the API routes have always been served from the exact same process, on the exact same origin, from the very first chapter onward. There was never a separate frontend dev server or a separate deployed frontend origin at any point in this course. WHY THIS TRACES BACK TO CHAPTER 1 ------------------------------ The absence of CORS anywhere in this course isn't something later chapters had to work around - it's a direct structural consequence of Chapter 1's own choice to serve the frontend from the same FastAPI process rather than as a genuinely separate application. Since frontend and backend requests were always same-origin, the situation CORS exists to handle never arose in the first place. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly explains what CORS is needed for, and correctly traces the reason this course never needed it back to Chapter 1's specific architectural choice of serving the frontend from the same origin as the API, rather than treating the absence of CORS as coincidental.