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?

  1. 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.example and api.example are different hosts. That makes them different origins.

    Origin consists of the scheme, host, and port. SchemeHostPort

    In short Origin compares scheme, host, and port.

  2. Read paths separately

    Changing https://app.example/home to https://app.example/settings changes 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.

Sources

Last reviewed 21 November 2026.

Next byte · The web What is the same-origin policy?