You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Background.md
+22-2Lines changed: 22 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,9 +28,9 @@ What could be done? The browser manufacturers implemented some hooks to allow da
28
28
Access-control-allow-Origin: *
29
29
```
30
30
At the same time they added a feature to allow the data publisher to specify other a limited set of other origins which would be allowed access. This makes running a bank easier if also the credit card company code can access your customers data.
This meant that anyone publishing public data has to add
35
35
36
36
```
@@ -39,6 +39,24 @@ Access-control-allow-Origin: *
39
39
in any response. This meant a huge amount of work for random open data publishers
40
40
all over the web, an effort which in many cases for many reasonable reasons was not done, leaving the data available to browsers, but unavailable to web apps.
41
41
42
+
The browser actually looks for these headers not on the request itself, but in
43
+
on a "Pre-flight" OPTIONS request which is inserted before the main request. So while the developer may see in the browser console only the main request, the number of round trips has in fact increased.
44
+
45
+
### Header blocking
46
+
47
+
As well as blocking the data, the CORS system blocks headers from the server to the web app.
48
+
To prevent this this, the server must send another [header](https://www.w3.org/TR/cors/#access-control-allow-headers-response-header):
This must include things like the Link: header which are normal headers blocked by the browser, and also any new headers the app and serve are using for any purpose.
53
+
54
+
### Method blocking
55
+
56
+
### Example
57
+
58
+
One solid server does CORS [this way](https://github.com/solid/node-solid-server/blob/master/lib/create-app.js#L26)
59
+
42
60
## The CORS twist
43
61
44
62
The twist is that in fact the designers of CORS make it even more difficult.
@@ -142,6 +160,8 @@ It seems also that Firefox showed the same behavior for in 2018-07
0 commit comments