Skip to content

CORS

In one line

CORS is a browser security mechanism that controls which cross-origin requests are allowed from web pages.

In simple words

CORS (Cross-Origin Resource Sharing) is a security feature enforced by browsers. When JavaScript on one origin (e.g., app.com) makes a request to a different origin (e.g., api.com), the browser checks if the server allows it via CORS headers.

Without CORS, any website could make requests to any API on behalf of the user — a security risk. CORS requires the server to include Access-Control-Allow-Origin in the response, specifying which origins are allowed. If the header is missing or does not match, the browser blocks the response.

For "non-simple" requests (PUT, DELETE, custom headers), the browser sends a "preflight" OPTIONS request first to check permissions. CORS is configured on the server, not the client — it is not something you fix in your frontend code.

Example

http
// Server response headers:
Access-Control-Allow-Origin: https://app.com
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: Content-Type, Authorization

Server CORS headers allowing requests from app.com with specific methods and headers.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary