Skip to content

Commit 4f7ce44

Browse files
committed
Add What Counts As Cross-Origin With CORS? as an HTTP til
1 parent b996320 commit 4f7ce44

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1212

13-
_989 TILs and counting..._
13+
_990 TILs and counting..._
1414

1515
---
1616

@@ -27,6 +27,7 @@ _989 TILs and counting..._
2727
* [Git](#git)
2828
* [Go](#go)
2929
* [HTML](#html)
30+
* [HTTP](#http)
3031
* [Internet](#internet)
3132
* [JavaScript](#javascript)
3233
* [jq](#jq)
@@ -300,6 +301,10 @@ _989 TILs and counting..._
300301
- [Render Text As Superscript](html/render-text-as-superscript.md)
301302
- [Submit A Form With A Button Outside The Form](html/submit-a-form-with-a-button-outside-the-form.md)
302303

304+
### HTTP
305+
306+
- [What Counts As Cross-Origin With CORS?](http/what-counts-as-cross-origin-with-cors.md)
307+
303308
### Internet
304309

305310
- [Add Emoji To GitHub Repository Description](internet/add-emoji-to-github-repository-description.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# What Counts As Cross-Origin With CORS?
2+
3+
When it comes to HTTP, an
4+
[origin](https://developer.mozilla.org/en-US/docs/Glossary/origin) is defined
5+
by several different aspects of the URL. This is important for understanding
6+
what qualifies as _same_ and _cross_-origin when dealing with
7+
[CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) (Cross-Origin
8+
Resource Sharing).
9+
10+
For something to be _same-origin_, it must have the same scheme (HTTP/HTTPS),
11+
the same host, and the same port. If any one of the scheme, host (including
12+
subdomains), or port is different, then it is not _same-origin_.
13+
14+
Here are some examples of different origins:
15+
16+
- `https://example.com` vs `http://example.com` (different scheme)
17+
- `https://example.com` vs `https://sub.example.com` (different host)
18+
- `https://example.com:3000` vs `https://example.com:5000` (different port)
19+
20+
As long as the scheme, host, and port match, they are the same origin. The path
21+
(everything following the origin) doesn't factor into the question of same
22+
origin.

0 commit comments

Comments
 (0)