Origin
An origin is the scheme, host, and port of a URL. Two URLs have the same origin only when all three parts match.
Concept
Updated
On this page
Example
URLs
https://example.com/a and https://example.com/b same origin http://example.com and http://example.com:80 same origin https://example.com and http://example.com other scheme https://example.com and https://www.example.com other host https://example.com and https://example.com:8080 other port
The path does not change the origin. Only the scheme, the host, and the port count.
How to use it
Read the origin in JavaScript. Compare the full origin string, not a part of the URL.
location.origin;
// "https://example.com"
new URL("https://example.com:8080/app").origin;
// "https://example.com:8080"The origin string has no port when the URL uses the default port, for example 443 for https.
Learn more
Sources