๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Web Development Intermediate

What is Cross-Origin Resource Sharing (CORS)?

An HTTP mechanism that allows web pages to request resources from a different domain than the one serving the page.

CORS relaxes the browser's Same-Origin Policy to enable controlled cross-domain requests. When JavaScript on domain-a.com fetches from api.domain-b.com, the browser sends an Origin header. The server responds with Access-Control-Allow-Origin specifying permitted origins. Complex requests (PUT, DELETE, custom headers) trigger a preflight OPTIONS request. Key headers include Access-Control-Allow-Methods (permitted HTTP methods), Access-Control-Allow-Headers (permitted request headers), Access-Control-Allow-Credentials (cookies), and Access-Control-Max-Age (preflight cache duration). CORS misconfiguration is a common source of both bugs (blocked requests) and security vulnerabilities (overly permissive origins).

Related Terms

MVC (Model-View-Controller)
An architectural pattern that separates an application into three components: data (Model), interface (View), and logic (Controller).
Canonical URL
An HTML element that tells search engines which URL is the preferred version of a page when duplicate or similar content exists at multiple URLs.
gRPC
A high-performance RPC framework using Protocol Buffers and HTTP/2 for efficient service-to-service communication.
CDN (Content Delivery Network)
A distributed network of servers that delivers web content to users from the geographically closest location.
SPA (Single Page Application)
A web application that loads a single HTML page and dynamically updates content without full page reloads.
JSON
JavaScript Object Notation โ€” a lightweight data interchange format that is easy for humans to read and machines to parse.
View All Web Development Terms โ†’