Skip to content

Commit

Permalink
Merge pull request #427 from MaskeZen/cross-origin-requests
Browse files Browse the repository at this point in the history
Fetch: Cross-Origin Requests
  • Loading branch information
joaquinelio committed Oct 30, 2020
2 parents c1588b9 + 106425e commit efd631b
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 155 deletions.
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`.
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.
16 changes: 8 additions & 8 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?
# ¿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: */*
Expand All @@ -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?

0 comments on commit efd631b

Please sign in to comment.