--- url: "https://web.dev/articles/same-site-same-origin" titulek: "\"Same-site\" and \"same-origin\" | Articles | web.dev" h1: "\"Same-site\" and \"same-origin\" Stay organized with collections Save and categorize content based on your preferences." popis: ""same-site" and "same-origin" are frequently cited but often misunderstood terms. This page explains what they are and how they are different." jazyk: "en" kanonicka: "https://web.dev/articles/same-site-same-origin" drobecky: ["Articles", ""Same-site" and "same-origin""] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 22:28:36" znaku: 6424 slov: 782 kodovani: "iso-8859-2" sha256: "b6bd64242ad24f7d6cc73f161aa462e38659e619c2ba0ea43dfe63e0f899c70e" --- "Same-site" and "same-origin" Stay organized with collections Save and categorize content based on your preferences. Eiji Kitamura "Same-site" and "same-origin" are frequently cited but often misunderstood terms. For example, they're used in the context of page transitions, `fetch()` requests, cookies, opening popups, embedded resources, and iframes. This page explains what they are and how they're different from each other. Origin The structure of an origin. "Origin" is a combination of a [scheme](https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Identifying_resources_on_the_Web#Scheme_or_protocol) (also known as the [protocol](https://developer.mozilla.org/docs/Glossary/Protocol), for example [HTTP](https://developer.mozilla.org/docs/Glossary/HTTP) or [HTTPS](https://developer.mozilla.org/docs/Glossary/HTTPS)), a [hostname](https://en.wikipedia.org/wiki/Hostname), and a [port](https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Identifying_resources_on_the_Web#Port) (if specified). For example, given a URL of `https://www.example.com:443/foo` , the "origin" is `https://www.example.com:443`. "Same-origin" and "cross-origin" Websites that have the same combination of scheme, hostname, and port are considered "same-origin". Everything else is considered "cross-origin". Origin A Origin B "Same-origin" or "cross-origin"? https://www.example.com:443 https://**www.evil.com**:443 Cross-origin: different domains https://**example.com**:443 Cross-origin: different subdomains https://**login**.example.com:443 Cross-origin: different subdomains **http**://www.example.com:443 Cross-origin: different schemes https://www.example.com:**80** Cross-origin: different ports **https://www.example.com:443** **Same-origin: exact match** **https://www.example.com** **Same-origin: implicit port number (443) matches** Site The parts of a URL that make up a site. [Top-level domains (TLDs)](https://developer.mozilla.org/docs/Glossary/TLD) such as `.com` and `.org` are listed in the [Root Zone Database](https://www.iana.org/domains/root/db). In the previous example, "site" is a combination of the [scheme](https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Identifying_resources_on_the_Web#Scheme_or_protocol), the [TLD](https://developer.mozilla.org/docs/Glossary/TLD), and the part of the domain just before it (We call it TLD+1). For example, given a URL of `https://www.example.com:443/foo`, the "site" is `https://example.com`. Public Suffix List and eTLD For domains with elements such as `.co.jp` or `.github.io`, just using `.jp` or `.io` isn't specific enough to identify the "site". There's no way to algorithmically determine the level of registrable domains for a particular TLD. To help with that, the [Public Suffix List](https://wiki.mozilla.org/Public_Suffix_List) defines a list of public suffixes, also called *effective TLDs (eTLDs)*. The list of eTLDs is maintained at [publicsuffix.org/list](https://publicsuffix.org/list/). To identify the "site" part of a domain that includes an eTLD, apply the same practice as the example with `.com`. Taking `https://www.project.github.io:443/foo` as an example, the scheme is `https`, the eTLD is `.github.io` and the eTLD+1 is `project.github.io`, so `https://project.github.io` is considered the "site" for this URL. The parts of a URL with an eTLD. "same-site" and "cross-site" Websites that have the same scheme and the same eTLD+1 are considered "same-site". Websites that have a different scheme or a different eTLD+1 are "cross-site". Origin A Origin B "Same-site" or "cross-site"? https://www.example.com:443 https://**www.evil.com**:443 Cross-site: different domains https://**login**.example.com:443 **Same-site: different subdomains don't matter** **http**://www.example.com:443 Cross-site: different schemes https://www.example.com:**80** **Same-site: different ports don't matter** **https://www.example.com:443** **Same-site: exact match** **https://www.example.com** **Same-site: ports don't matter** "Schemeless same-site" The definition of "same-site" changed to include the URL scheme as part of the site to prevent HTTP being used as a [weak channel](https://tools.ietf.org/html/draft-west-cookie-incrementalism-01#page-8). The older concept of "same-site" without scheme comparison is now called "schemeless same-site". For example, `http://www.example.com` and `https://www.example.com` are considered schemeless same-site but not same-site, because only the eTLD+1 part matters and the scheme isn't considered. Origin A Origin B "Schemeless same-site" or "cross-site"? https://www.example.com:443 https://**www.evil.com**:443 Cross-site: different domains https://**login**.example.com:443 **Schemeless same-site: different subdomains don't matter** **http**://www.example.com:443 **Schemeless same-site: different schemes don't matter** https://www.example.com:**80** **Schemeless same-site: different ports don't matter** **https://www.example.com:443** **Schemeless same-site: exact match** **https://www.example.com** **Schemeless same-site: ports don't matter** How to check if a request is "same-site", "same-origin", or "cross-site" Browser Support 76 79 90 16.4 [Source](https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/Sec-Fetch-Site) All modern browsers send requests with a [`Sec-Fetch-Site` HTTP header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Sec-Fetch-Site). The header has one of the following values: `cross-site` `same-site` (refers to schemeful same-site) `same-origin` `none` You can examine the value of `Sec-Fetch-Site` to determine whether the request is same-site, same-origin, or cross-site. You can reasonably trust the value of the `Sec-Fetch-Site` header, because: [HTTP headers starting with `Sec-` can't be modified by JavaScript](https://www.w3.org/TR/fetch-metadata/#sec-prefix) The browser always sets these headings. [Previous arrow_back What are security attacks?](/articles/security-attacks) [Next Security headers quick reference arrow_forward](/articles/security-headers) Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2020-04-15 UTC.