This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Commit 202a0c8
committed
Add a CORS header allowing browser-based clients to consume the API.
The MaveDB API is publicly accessible and can be consumed by any client. However, it is currently consumed mainly by server-side clients such as mavevis. Browser-based clients, including any MaveDB client application that is not served by the Django application, generally require CORS headers granting explicit permission to consume the API. To allow this, we add a simple HTTP response header granting access to clients from any domain:
Access-Control-Allow-Origin="*"
The header is added using Django middleware, with support for Django 1 (though a draft of a version for later Django versions is included and commented out). For current Django versions, there are also Django middleware packages available for this purpose, which provide configuration-driven CORS headers and are useful in case one wants to limit access to specific clients.1 parent b2ab961 commit 202a0c8
2 files changed
+47
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| |||
0 commit comments