Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fetch: Cross-Origin Requests
  • Loading branch information
Nordtonito authored and Vitalii Nesteruk committed Aug 23, 2022
commit 4023cf38542a58881c5d38cbcb881959c9d54bed
10 changes: 5 additions & 5 deletions 5-network/05-fetch-crossorigin/1-do-we-need-origin/solution.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
We need `Origin`, because sometimes `Referer` is absent. For instance, when we `fetch` HTTP-page from HTTPS (access less secure from more secure), then there's no `Referer`.
Нам потрібен `Origin`, тому що іноді `Referer` відсутній. Наприклад, коли ми запитуємо через `fetch` HTTP-сторінку з HTTPS (доступ до менш безпечного з більш безпечного), тоді немає `Referer`.

The [Content Security Policy](http://en.wikipedia.org/wiki/Content_Security_Policy) may forbid sending a `Referer`.
[Content Security Policy](http://en.wikipedia.org/wiki/Content_Security_Policy) може забороняти надсилання `Referer`.

As we'll see, `fetch` has options that prevent sending the `Referer` and even allow to change it (within the same site).
Як ми побачимо, `fetch` має параметри, які забороняють надсилати `Referer` і навіть дозволяють змінювати його (в межах того самого сайту).

By specification, `Referer` is an optional HTTP-header.
За специфікацією `Referer` є необов'язковим HTTP-заголовком.

Exactly because `Referer` is unreliable, `Origin` was invented. The browser guarantees correct `Origin` for cross-origin requests.
Саме тому, що `Referer` є ненадійним, було винайдено `Origin`. Браузер гарантує правильне `Origin` для запитів між різними джерелами.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Саме тому, що `Referer` є ненадійним, було винайдено `Origin`. Браузер гарантує правильне `Origin` для запитів між різними джерелами.
Саме тому, що `Referer` є ненадійним, було винайдено `Origin`. Браузер гарантує правильний `Origin` для запитів між різними джерелами.

14 changes: 7 additions & 7 deletions 5-network/05-fetch-crossorigin/1-do-we-need-origin/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ importance: 5

---

# Why do we need Origin?
# Навіщо нам Origin?

As you probably know, there's HTTP-header `Referer`, that usually contains an url of the page which initiated a network request.
Як ви, мабуть, знаєте, існує HTTP-заголовок `Referer`, який зазвичай містить URL-адресу сторінки, що ініціювала мережевий запит.

For instance, when fetching `http://google.com` from `http://javascript.info/some/url`, the headers look like this:
Наприклад, під час отримання `http://google.com` з `http://javascript.info/some/url` заголовки виглядають так:

```
Accept: */*
Expand All @@ -20,9 +20,9 @@ Referer: http://javascript.info/some/url
*/!*
```

As you can see, both `Referer` and `Origin` are present.
Як бачите, присутні і `Referer`, і `Origin`.

The questions:
Питання:

1. Why `Origin` is needed, if `Referer` has even more information?
2. Is it possible that there's no `Referer` or `Origin`, or is it incorrect?
1. Навіщо потрібен `Origin`, якщо `Referer` містить ще більше інформації?
2. Чи можливо, що немає `Referer` чи `Origin`, або ж це неправильно?
Loading