CORS (Cross-Origin Resource Sharing) is a security mechanism implemented by web browsers to control which websites can access resources from other domains. By default, browsers block cross-origin requests—requests made from one website to another domain, protocol, or port—for security reasons.
Without CORS, malicious websites could secretly send requests to other servers (e.g., API servers or banking sites), potentially stealing or misusing sensitive data (Cross-Site Request Forgery, CSRF). CORS ensures that only explicitly allowed websites can access resources.
When a web application makes a cross-origin request (e.g., from http://example.com
to https://api.example.com
), the browser automatically sends a CORS request. The server must then respond with specific HTTP headers to indicate whether the request is allowed:
Without CORS headers:
The browser blocks the request.
With CORS headers:
The server can respond with Access-Control-Allow-Origin: *
(allowing all domains) or a specific domain (Access-Control-Allow-Origin: https://example.com
). This enables access.
For certain requests (e.g., PUT
, DELETE
, or requests with custom headers), the browser sends a preflight request using the OPTIONS
method. The server must respond with the correct CORS headers to allow the main request.
CORS is a crucial security measure that prevents unauthorized websites from accessing foreign resources. Developers must configure the correct server-side headers to allow legitimate clients to access the data.
Duplicate Content refers to identical or very similar text appearing on multiple web pages, either within the same website or across different websites. This can happen unintentionally (e.g., due to technical issues) or deliberately (e.g., through content copying). Search engines like Google generally dislike duplicate content because it can harm the user experience and dilute search results.
Internal Duplicate Content: The same content is accessible via multiple URLs on the same website. Example: A page is available with and without "www" or with different URL parameters.
External Duplicate Content: The same content appears on multiple websites. Example: A text is copied from another site, or several websites use the same manufacturer-provided product descriptions.
Avoiding duplicate content is essential to maximize a website's visibility and performance.
A Canonical Link (or "Canonical Tag") is an HTML element used to signal to search engines like Google which URL is the "canonical" or preferred version of a webpage. It helps avoid issues with duplicate content when multiple URLs have similar or identical content.
If a website is accessible through multiple URLs (e.g., with or without "www," with or without parameters), search engines might treat them as separate pages. This can negatively impact rankings because the relevance and authority are spread across multiple URLs.
A canonical link specifies which URL should be treated as the main version.
The canonical tag is added in the <head>
section of the HTML code, like this:
<link rel="canonical" href="https://www.example.com/preferred-url" />
An online store has the same product available under different URLs:
https://www.store.com/product?color=blue
https://www.store.com/product?color=red
Using a canonical tag, you can declare https://www.store.com/product
as the main URL.
A webpage is a digital document that can be accessed via the internet and displayed in a web browser. It is part of a larger entity – a website – and typically contains text, images, videos, links, and other interactive elements.
https://www.example.com/contact
.A webpage is delivered by a web server and transmitted to the user's browser via HTTP or HTTPS protocols. The browser interprets the code (HTML, CSS, JavaScript) and renders the page visually.
In short, a webpage is a single document that can be accessed online to deliver information or services. It is an essential component of a website, which consists of multiple such pages.