diff --git a/5-network/05-fetch-crossorigin/1-do-we-need-origin/solution.md b/5-network/05-fetch-crossorigin/1-do-we-need-origin/solution.md index d44494e18..6a9e1ff61 100644 --- a/5-network/05-fetch-crossorigin/1-do-we-need-origin/solution.md +++ b/5-network/05-fetch-crossorigin/1-do-we-need-origin/solution.md @@ -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`. +Kita membutuhkan *`Origin`*, karena terkadang *`Referer`* tidak digunakan. Misalnya, saat kita *`fetch`* halaman HTTP dari HTTPS(mengakses yang kurang aman dari yang aman), maka tidak memakai *`Referer`*. -The [Content Security Policy](http://en.wikipedia.org/wiki/Content_Security_Policy) may forbid sending a `Referer`. +[Kebijakan keamanan konten](http://en.wikipedia.org/wiki/Content_Security_Policy) mungkin akan melarang untuk pengiriman *`Referer`*. -As we'll see, `fetch` has options that prevent sending the `Referer` and even allow to change it (within the same site). +Seperti yang kita lihat, *`fetch`* memiliki opsi untuk mencegah mengirim `Referer`, dan mengizinkan untuk mengubahnya ( di situs yang sama). -By specification, `Referer` is an optional HTTP-header. +Dari Spesifikasi, *`Referer`* adalah header HTTP opsional. -Exactly because `Referer` is unreliable, `Origin` was invented. The browser guarantees correct `Origin` for cross-origin requests. +Tepatnya karena *`Referer`* tidak dapat diandalkan, dibuat lah `Origin`. Browser menjamin *`Origin` *yang benar untuk *request* *cross-origin*. \ No newline at end of file diff --git a/5-network/05-fetch-crossorigin/1-do-we-need-origin/task.md b/5-network/05-fetch-crossorigin/1-do-we-need-origin/task.md index fb8142a3b..c72a5c739 100644 --- a/5-network/05-fetch-crossorigin/1-do-we-need-origin/task.md +++ b/5-network/05-fetch-crossorigin/1-do-we-need-origin/task.md @@ -2,11 +2,11 @@ importance: 5 --- -# Why do we need Origin? +# Kenapa kita membutuhkan Origin? -As you probably know, there's HTTP-header `Referer`, that usually contains an url of the page which initiated a network request. +Seperti yang kamu ketahui, Ada pembaca *header* HTTP *`Referer`*, yang biasanya berisi *url* dari halaman yang dimulai dari *request* jaringan. -For instance, when fetching `http://google.com` from `http://javascript.info/some/url`, the headers look like this: +Misalnya, saat pengambilan `http://google.com` dari `http://javacript.info/some/url`, *header* terlihat seperti ini: ``` Accept: */* @@ -20,9 +20,9 @@ Referer: http://javascript.info/some/url */!* ``` -As you can see, both `Referer` and `Origin` are present. +Seperti yang kamu lihat, baik *`Referer`* dan *`Origin`* ada. -The questions: +Pertanyaan: -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. Kenapa *`Origin`* dibutuhkan, jika *`Referer`* memiliki lebih banyak informasi? +2. Apakah mungkin jika *`fetch`* tidak memakai *`Referer`* atau *`Origin`*, atau apakah *`fetch`* itu salah? diff --git a/5-network/05-fetch-crossorigin/article.md b/5-network/05-fetch-crossorigin/article.md index 0c1429697..9d58bae7f 100644 --- a/5-network/05-fetch-crossorigin/article.md +++ b/5-network/05-fetch-crossorigin/article.md @@ -1,42 +1,43 @@ -# Fetch: Cross-Origin Requests +# Fetch: *request Cross-Origin* -If we send a `fetch` request to another web-site, it will probably fail. +Jika kita mengirim *request* *`fetch`* dari situs web lain, itu mungkin akan gagal. -For instance, let's try fetching `http://example.com`: +Misalnya, mari coba *fetch* dari `http://example.com`: ```js run async try { await fetch('http://example.com'); } catch(err) { - alert(err); // Failed to fetch + alert(err); // Failed to fetch (Gagal untuk *fetch*) } ``` -Fetch fails, as expected. +*Fetch* akan gagal, seperti yang diperkirakan. -The core concept here is *origin* -- a domain/port/protocol triplet. +Konsep dasarnya dari *origin* -- tiga serangkai *domain*/port/protokol. -Cross-origin requests -- those sent to another domain (even a subdomain) or protocol or port -- require special headers from the remote side. +*request cross-origin* -- yang dikirimkan ke *domain* lain (atau sob*domain*) atau protokol atau *port* -- membutuhkan *header* khusus dari sisi *remote*. -That policy is called "CORS": Cross-Origin Resource Sharing. +Kebijakan yang disebut *"CORS"*: *Cross-Origin Resource Sharing*. -## Why is CORS needed? A brief history +## Kenapa *CORS* dibutuhkan? sejarah singkat -CORS exists to protect the internet from evil hackers. +*CORS* ada untuk melindungi internet dari *hacker* jahat. Seriously. Let's make a very brief historical digression. +Serius, Mari kita membuat sejarah yang singkat. -**For many years a script from one site could not access the content of another site.** +**Untuk bertahun-tahun skrip dari satu situs tidak bisa mengakses konten dari situs lainnya** -That simple, yet powerful rule was a foundation of the internet security. E.g. an evil script from website `hacker.com` could not access user's mailbox at website `gmail.com`. People felt safe. +Aturan simpel yang kuat tersebut adalah dasar dari keamanan internet. Contoh skrip jahat dari situs web `hacker.com` tidak bisa mengakses pesan dari pengguna di situs web `gmail.com`. Orang-orang merasa aman. -JavaScript also did not have any special methods to perform network requests at that time. It was a toy language to decorate a web page. +Javascript juga tidak memiliki metode khusus untuk menampilkan *request* jaringan pada saat itu. Ini adalah bahasa mainan untuk menghias halaman web. -But web developers demanded more power. A variety of tricks were invented to work around the limitation and make requests to other websites. +Tetapi pengembang web menuntut lebih banyak kuasa. Bebagai trik dibuat untuk mengatasi batasan dan membuat *request* kepada situs web lainnya. -### Using forms +### Menggunakan Form -One way to communicate with another server was to submit a `
` there. People submitted it into ` */!* - + *!* */!* @@ -52,91 +53,94 @@ One way to communicate with another server was to submit a `` there. Peopl
``` -So, it was possible to make a GET/POST request to another site, even without networking methods, as forms can send data anywhere. But as it's forbidden to access the content of an `