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..b6d71b3c7 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`. +Necesitamos la cabecera `Origin`, ya que en algunos casos `Referer` no está presente. Por ejemplo, cuando realizamos un `fetch` a una página HTTP desde una HTTPS (acceder a un sitio menos seguro desde uno más seguro), en ese caso no tendremos el campo `Referer`. -The [Content Security Policy](http://en.wikipedia.org/wiki/Content_Security_Policy) may forbid sending a `Referer`. +La [Política de seguridad de contenido](http://en.wikipedia.org/wiki/Content_Security_Policy) puede prohibir el envío de `Referer`. -As we'll see, `fetch` has options that prevent sending the `Referer` and even allow to change it (within the same site). +Como veremos, `fetch` tiene opciones con las que es posible evitar el envío de `Referer` e incluso permite su modificación (dentro del mismo sitio). -By specification, `Referer` is an optional HTTP-header. +Por especificación, `Referer` es una cabecera HTTP opcional. -Exactly because `Referer` is unreliable, `Origin` was invented. The browser guarantees correct `Origin` for cross-origin requests. +Por el hecho de que `Referer` no es confiable, la cabecera `Origin` ha sido creada. El navegador garantiza el envío correcto de `Origin` para las solicitudes de origen cruzado. 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..85d98558c 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? +# ¿Por que necesitamos el origen (Origin)? -As you probably know, there's HTTP-header `Referer`, that usually contains an url of the page which initiated a network request. +Como seguramente ya sepas, existe la cabecera HTTP `Referer`, la cual por lo general contiene la url del sitio que generó la solicitud. -For instance, when fetching `http://google.com` from `http://javascript.info/some/url`, the headers look like this: +Por ejemplo, cuando solicitamos la url `http://google.com` desde `http://javascript.info/alguna/url`, las cabeceras se ven de este modo: ``` Accept: */* @@ -16,13 +16,13 @@ Connection: keep-alive Host: google.com *!* Origin: http://javascript.info -Referer: http://javascript.info/some/url +Referer: http://javascript.info/alguna/url */!* ``` -As you can see, both `Referer` and `Origin` are present. +Tal como se puede ver, tanto `Referer` como `Origin` están presentes. -The questions: +Las preguntas: -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. ¿Por qué la cabecera `Origin` es necesaria, si `Referer` contiene incluso más información? +2. ¿Es posible que no se incluya `Referer` u `Origin`, o que contengan datos incorrectos? diff --git a/5-network/05-fetch-crossorigin/article.md b/5-network/05-fetch-crossorigin/article.md index 0c1429697..bd490d1d3 100644 --- a/5-network/05-fetch-crossorigin/article.md +++ b/5-network/05-fetch-crossorigin/article.md @@ -1,8 +1,8 @@ # Fetch: Cross-Origin Requests -If we send a `fetch` request to another web-site, it will probably fail. +Si enviamos una petición `fetch` hacia otro sitio seguramente fallará. -For instance, let's try fetching `http://example.com`: +Por ejemplo, probemos realizar una petición a `http://example.com`: ```js run async try { @@ -12,39 +12,39 @@ try { } ``` -Fetch fails, as expected. +El método fetch falla, tal como lo esperábamos. -The core concept here is *origin* -- a domain/port/protocol triplet. +El concepto clave aquí es *el origen* (*origin*), triple combinación de dominio/puerto/protocolo. -Cross-origin requests -- those sent to another domain (even a subdomain) or protocol or port -- require special headers from the remote side. +Las solicitudes de origen cruzado `Cross-origin requests` (aquellas que son enviadas hacia otro dominio --incluso subdominio--, protocolo o puerto), requieren de unas cabeceras especiales desde el sitio remoto. -That policy is called "CORS": Cross-Origin Resource Sharing. +Esta política es denominada "CORS", por sus siglas en inglés Cross-Origin Resource Sharing. -## Why is CORS needed? A brief history +## ¿Por que CORS es necesario?, Una breve historia -CORS exists to protect the internet from evil hackers. +CORS existe para proteger Internet de los hackers malvados. -Seriously. Let's make a very brief historical digression. +En verdad... Déjame contarte un breve resumen de esta historia. -**For many years a script from one site could not access the content of another site.** +**Durante muchos años un script de un sitio no podía acceder al contenido de otro sitio.** -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. +Esta simple, pero poderosa regla, fue parte fundacional de la seguridad de Internet. Ej: Un script malicioso desde el sitio `hacker.com` no podía acceder a la casilla de correo en el sitio `gmail.com`. La gente se podía sentir segura. -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. +Así mismo en ese momento, JavaScript no tenía ningún método especial para realizar solicitudes de red. Simplemente era un lenguaje juguete para decorar páginas web. -But web developers demanded more power. A variety of tricks were invented to work around the limitation and make requests to other websites. +Pero los desarrolladores web demandaron más poder. Una variedad de trucos fueron inventados para poder pasar por alto las limitaciones, y realizar solicitudes a otros sitios. -### Using forms +### Utilizando formularios -One way to communicate with another server was to submit a `