liveBook · Manning

CORS

As explained in Acing the Frontend Interview

Cross-Origin Resource Sharing is a browser and HTTP mechanism that controls whether a web origin may access resources from another origin.

CORS controls whether browser JavaScript may access resources across origins. In an n-tier system, a separately deployed frontend and backend require explicit backend permission because of the same-origin policy. section 6.1

Interview scenario

A UI at https://ui.myapp.com calls an API at https://api.myapp.com. Configure the API to allow that origin, required methods and headers, and credentials; verify the OPTIONS response with curl. A React + Vite development proxy can alternatively route a request such as /apiproxy/api/breeds/image/random to the target API. section 6.1

How Acing the Frontend Interview covers it

How deep it goes
Explains same-origin policy, response headers, credentials, preflight handling, curl verification, and a development proxy.
Examples
Uses an Express middleware configuration, an OPTIONS curl response, and a React + Vite proxied dog-image request.
What you can do after
Configure CORS headers, handle preflight requests, verify responses, and apply a React + Vite API proxy.
How it connects
Connects same-origin policy, HTTP, n-tier architecture, API gateways, Backend-for-Frontend, React, and Vite proxies.

Also explained in

Compare how 8 books explain CORS →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.