A script on one page should not automatically read private data from every other site you visit. Browsers use origins to separate those permissions. For the http and https URLs here, an origin is the combination of scheme, host, and effective port. Effective means the stated port or the scheme’s default when omitted.
The same-origin policy limits how a document or script can interact with resources from a different origin. In the basic cases here, a script cannot read another origin’s response merely because it can name the URL. A path identifies a resource within the origin; changing only the path does not create a new origin.
This browser policy is separate from server authorization. Some cross-origin actions, such as ordinary form submissions, can still send requests. A blocked response read is therefore not proof that no request was sent. The server must protect its data and actions regardless of which client sends a request.
Before you begin
- Recommended first
- Hosts, LANs, and the internet, Ports and the services behind the common ones, TCP, UDP, and the three-way handshake, Variables, strings, lists, dicts, conditions, loops, How a web app is put together
- Estimated time
- 15 min reading, 15 min activity. Setup and optional practice may take longer.
- Where you work
- Use the complete printed cards with paper or a text editor for notes. No account, external target, or installation is required. A local HTML file can be read as source; that reading does not perform an HTTP exchange. The curl lesson gives a separate optional loopback-lab procedure.
- Without a lab
- The cards provide the names, byte counts, requests, responses, and stored records needed for the activity. Make a prediction and compare with the supplied reasoning; a practical run can wait. Reading works without JavaScript. Answer checking needs JavaScript and a secure context, normally HTTPS or a local preview. Saving additionally needs usable browser storage.
After this lesson you can:
- Compare two URLs by scheme, host, and port, and leave the path out.
- Separate a browser limit on reading from a request that can still be sent.
- Explain one fictional web flow from the name through the origin boundary.
01Example
Compare this worked pair by writing the three parts for each URL. Both use http and 127.0.0.1, but ports 7000 and 7443 differ. They are different origins. These are fictional comparisons; no browser accessed either address.
http://127.0.0.1:7000/one
http://127.0.0.1:7443/one
Same scheme, same host, ports 7000 and 7443.
The path is outside the comparison.02Three parts
Use the effective scheme, host, and port together. For http, an omitted port means 80; for https, it means 443. Thus an omitted default and an explicitly written default refer to the same port. A changed scheme or changed port makes an origin different even if the host matches.
For HTTP URLs, paths, queries, and fragments are outside the origin comparison. The fragment is the part after # used to identify a location within a resource. Two different paths under the same scheme, host, and port stay in one origin.
A file URL reads a local resource and does not follow the same simple web-origin model. Browsers may give local files opaque origins, identities that do not behave like a shared HTTP host and port. Do not assume nearby files share permissions. The printed file URL supplies a different kind of access from http://127.0.0.1:9000; no browser-specific local-file behavior is claimed.
Servers can deliberately allow some cross-origin response sharing through Cross-Origin Resource Sharing, or CORS, a browser mechanism based on response headers. That allowance is separate from authenticating an account and authorizing access. curl is outside the browser’s same-origin restrictions, which is another reason server checks remain necessary.
Compare scheme, host and effective port; these ports differ, and the path is explicitly excluded from the origin comparison.Model. A teaching model drawn by hand. It shows the idea, not real tool output.
Read the full explanation below.
| Field | http://127.0.0.1:7000/one | http://127.0.0.1:7443/one |
|---|---|---|
| Scheme | http | http |
| Host | 127.0.0.1 | 127.0.0.1 |
| Effective port | 7000 | 7443 |
| Path — excluded | /one | /one |
Both URLs use http and 127.0.0.1.
Both URLs use http and 127.0.0.1.
Follow the explanation
- Both URLs use http and 127.0.0.1.
- Ports 7000 and 7443 differ, so these origins differ.
- The matching /one path does not change the origin result. Browser response-reading restrictions do not prove a request was never sent.
Read every state and value
1. Both URLs use http and 127.0.0.1.
- Selected Comparison
- same
- Highlighted Field
- Scheme · Host
2. Ports 7000 and 7443 differ, so these origins differ.
- Selected Comparison
- port
- Highlighted Field
- port
3. The matching /one path does not change the origin result. Browser response-reading restrictions do not prove a request was never sent.
- Selected Comparison
- excluded
- Highlighted Field
- Path — excluded
03Sort three pairs
Use the three fresh pairs on the origin cards. The outcome card is fictional evidence for the basic policy case, with no special cross-origin sharing permission. Decide from the three URL parts before reading those outcomes.
Original fictional pairs. No browser compared them.
For these HTTP URLs, an origin is scheme, host, and effective port.
Effective means the printed port, or the scheme’s default when omitted.
The path is outside that triple.
Worked pair
http://127.0.0.1:7000/one
http://127.0.0.1:7443/one
Scheme and host match. Ports 7000 and 7443 differ.
Activity pairs
Pair 1
http://127.0.0.1:9000/notes
http://127.0.0.1:9000/other
The path differs. Scheme, host, and port match.
Pair 2
http://127.0.0.1:9000/notes
http://127.0.0.1:9001/notes
The port differs.
Pair 3
https://127.0.0.1:9000/notes
http://127.0.0.1:9000/notes
The scheme differs. Both lines print port 9000. The schemes still differ, so the origins differ.
Check: pair 1 is the same origin.
Original fictional browser outcomes for the activity pairs.
Assume no special cross-origin sharing permission in these basic cases.
Pair 1: a script on the first page read the second page's text.
Pair 2: the read was blocked.
Pair 3: the read was blocked.
A form on the first page of pair 2 can still name the other port as its target.
Sending that form is a different fact from reading the response.
curl is a client outside this browser policy.
The server still decides who may read the stored row.
file:///home/desk/lab-site/note.txt
This is a file URL. It is a different reference from the origin http://127.0.0.1:9000.
Local files may have opaque origins; this card makes no browser-specific permission claim.
- For each URL, write scheme, host, and effective port. Keep its path in a separate column so it cannot accidentally decide the origin.
- In pair 1, compare matching http, 127.0.0.1, and 9000. Its paths differ but its origin matches. Pair 2 changes the port; pair 3 changes the scheme.
- Compare with the fictional outcomes: pair 1’s read succeeds and the other reads are blocked. State that these are model outcomes, not a browser run.
- Explain why a form targeting another origin can still be sent in this ordinary case even when a script’s response read is blocked. Stop without opening any target or changing browser settings.
04Names and requests case
Finish the module and stage with the separate names-and-requests case. It combines DNS, HTTP, a form, session state, and origin comparison. Use its seven-line rubric to review an evidence note, while keeping the named DNS example distinct from the loopback request.
Names and requests case. Original fiction. Self-review activity.
No query, request, or browser comparison was performed.
Name
shelf.lab.invalid
A record: 192.0.2.44
This case has no AAAA line.
The later loopback request is separate; no resolution from this name
to the loopback address is shown.
Request
GET /note HTTP/1.1
Host: 127.0.0.1:8000
Status: 200
Body word: kept
Form
Label: Note
name attribute: slip
Predicted urlencoded body: slip=kept
Session
Cookie identifier: lab-sid-04
Stored role on the server: member
The decision that reads the row sits on the server.
Guided origin comparison, reusing pair 1 from origin-cards.txt
http://127.0.0.1:9000/notes
http://127.0.0.1:9000/other
The scheme, host, and port match. These paths share one origin.
The server still enforces the stored row.
Independent URL evidence for the later question
http://127.0.0.1:8000/note
http://127.0.0.1:8001/note
Leave this comparison for the question; no conclusion is supplied here.
File URL
file:///home/desk/lab-site/note.txt
Opening that file reads text on disk.
It is a different reference from the HTTP origin http://127.0.0.1:8000.
Rubric for notes
1. The IPv4 on the A record is 192.0.2.44.
2. The method is GET and the status is 200.
3. The submitted key is slip, taken from the name attribute.
4. The session decision uses the server's stored role, member.
5. In the guided 9000 pair, the three origin components match; paths do not decide the comparison.
6. A blocked browser read leaves the server's own check in place.
7. The file URL is a different kind of reference from that HTTP origin.
- Record the fictional A-record address for shelf.lab.invalid. Separately record the request to the loopback host, its method GET, status 200, and body word kept. The card does not show a DNS connection between those two hosts.
- Read the form’s name attribute slip and predict slip=kept. Then identify session identifier lab-sid-04 and stored role member as different values.
- For the synthesis origin reasoning, reuse pair 1 on port 9000: /notes and /other share the scheme, host, and port despite different paths. Explain why that browser comparison does not replace the server’s trusted-state check. Keep the separate 8000/8001 URL evidence for the question.
- Distinguish the local file URL from the HTTP URL. Review your note against all seven rubric lines and stop. You have traced the supplied model; a real DNS query, page load, certificate check, or form submission would need separate observation.
05Optional challenge
For about ten extra minutes, explain why a blocked script read is insufficient protection for a state-changing action. Your answer should say that some requests can still be sent, that a request is different from reading its response, and that the server needs its own checks. No cross-origin request is required.
06Fresh cases for the checks
Use these fictional cases for the checks below. They have different inputs from the worked examples. Read them here or make notes; no installation or external service is needed.
Origin case A: independent URL comparisonsOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Base: https://panel.grove.invalid/one
P: https://panel.grove.invalid:443/two?x=1
Q: https://panel.grove.invalid:8443/one
R: http://panel.grove.invalid/one
S: https://other.grove.invalid/one
For https, omitted port means 443. For http, omitted port means 80. Paths and queries are not origin components.
Origin case B: supplied browser outcomeOwned fixture. An original file made for this course. Follow the activity's instructions in your own lab.
Page script from https://panel.grove.invalid sends an allowed request to https://archive.grove.invalid. The request reaches the server. No CORS permission is present. The browser blocks this script from reading the response. The server receives a state-changing request and must enforce its own permission rules.
07Explain your prediction
Optional written self-check: Compare scheme, host and effective port explicitly. Keep request sending, browser response reading and server authorization as separate decisions, and limit the simple origin model to the HTTP URLs supplied.
08Common mistakes
If pair 2 is marked same-origin, compare the port numbers explicitly. Matching only the host leaves out one required part.
If pair 3 is marked same-origin, compare the schemes before looking at the identical printed port. http and https still differ.
If a blocked read is described as the server rejecting an account, separate the enforcement points. The browser limits response access; the server must make its own authorization decision.
References
- RFC 6454: The Web Origin Concept
Sections 3–5 provide origin background and isolation principles; the URL Standard supplies the web URL algorithm.
- RFC 9110: HTTP semantics
Sections 4.2.1 and 4.2.2 explain http/https schemes, default ports, and protected HTTP.
- URL Standard
Section 4.7 gives the current http/https origin tuple and the local-file qualification.
- MDN: Cross-Origin Resource Sharing
Explains the explicit browser mechanism for permitting selected cross-origin response reads.
Next is the first lesson of Security.