Cross-Origin Resource Sharing
CORS controls browser access to responses across origin boundaries. It replaces neither API login nor permission checks.
Allowing another origin to read responses
Cross-Origin Resource Sharing, or CORS, is an HTTP-header mechanism. A server uses it to indicate which other origins may access its responses from browser code. An origin includes scheme, host and port. Enforcement happens in the browser; CORS is not an API login.
Consider the portal and API separately
A fictional portal at https://portal.example wants to read project data from https://api.example/projects. The API can allow the portal origin through Access-Control-Allow-Origin. Depending on the method and headers, the browser first asks with OPTIONS whether the actual call is permitted. This check is called a preflight; it does not happen for every call.
For other calls, the request may already reach the server even though the browser subsequently withholds the response from the script. A CORS error therefore does not prove that nothing happened on the server.
If session cookies are to be included, credential settings must also agree. Such responses require an explicit origin rather than the wildcard *; Access-Control-Allow-Credentials is relevant too. The browser’s cookie rules still apply. Independently, the API checks identity and permissions for the requested project data.
Sources
Related terms
- Same-origin policyThe same-origin policy limits browser access between different origins. A different page path alone does not create a new origin.
- Cross-site request forgery (CSRF)CSRF exploits a signed-in session for an unwanted request. A session cookie alone does not prove that the user intended the action.
- SameSite cookieSameSite affects cookie inclusion in cross-site requests. The choice must fit login and navigation flows; CSRF protection remains necessary.
- Server-sent eventsServer-sent events carry text notifications from server to client over HTTP, for example about the progress of a background job.
- Entity tagAn ETag identifies a particular representation version of an HTTP resource and supports conditional reads or changes.
- Electronic Data InterchangeEDI transfers structured business documents between systems. Format, partner profile, data mapping and responses need to agree.
Your project with ASES
Describe your project to us. We will get back to you with an initial assessment.