The web Web origins 2 min read
What is a web origin?
Your app runs at https://app.example. Its API runs at https://api.example. Both are under the same domain. Does the browser treat them as the same origin?
-
Compare three parts of the URL
For these HTTPS URLs, the browser compares scheme, host, and port. Their schemes and effective ports match, but
app.exampleandapi.exampleare different hosts. That makes them different origins.In short Origin compares scheme, host, and port.
-
Read paths separately
Changing
https://app.example/hometohttps://app.example/settingschanges the path while keeping all three origin parts the same. An explicit default HTTPS port,:443, also leaves the origin the same.In short A new path keeps the same origin. A different host changes it.
Where this applies
Some URLs and sandboxed documents have opaque origins. Comparing three URL parts is useful for ordinary HTTP and HTTPS URLs.
Keep this
Compare origins before debugging browser access.
Check the scheme, host, and effective port of both URLs.