v145 · Origin API · Explorer
Origin Object Explorer
Construct Origin objects from any URL and compare them with isSameOrigin() and isSameSite(). See how port, scheme, and subdomain changes cross origin or site boundaries.
Requires Chrome 145+. The Origin constructor is only available in supported browsers.
URL A
URL B
how it works
// Construct Origin objects from serialized origins or full URLs
const a = new Origin("https://app.example.com:8080");
const b = new Origin("https://app.example.com");
// Same origin: scheme + host + port must all match exactly
a.isSameOrigin(b); // false — port differs (8080 vs 443)
// Same site: eTLD+1 must match, scheme must match
a.isSameSite(b); // true — both use https://example.com
// Works with current page's origin
const pageOrigin = new Origin(window.location.origin);
pageOrigin.isSameOrigin(new Origin("https://api.example.com"));
// Common trap: string comparison hides edge cases
// "null" === "null" accidentally matches two opaque origins
// isSameOrigin() handles opaque origins correctly
see also
- Cross-Origin Safety Checker — test any two URLs across origin/site boundaries
- Introducing the Origin API overview
- ChromeStatus entry