ecotaxa / ecotaxa_back

Backend of the EcoTaxa application
GNU General Public License v3.0
6 stars 5 forks source link

Add a CORS header to API calls #64

Open grololo06 opened 1 year ago

grololo06 commented 1 year ago

We have the problem with EcoTaxoGuide that the front-end app (using Angular) refuses to connect to the API because it does not provide a correct CORS (https://developer.mozilla.org/fr/docs/Web/HTTP/CORS/Errors/CORSMissingAllowOrigin).

E.g.: https://ecotaxa.obs-vlfr.fr/api/object/25557188

Hacked today a "solution" in nginx, but the proper fix should be in the back-end: https://fastapi.tiangolo.com/tutorial/cors/

grololo06 commented 1 year ago

        location /api/object/  {
                proxy_pass http://localhost:8000;
                add_header 'Access-Control-Allow-Origin' '*' always;
        }
        location /api/vault/  {
                proxy_pass http://localhost:8000;
                add_header 'Access-Control-Allow-Origin' '*' always;
        }