digitalfabrik / coldaid-backend

A fork of the new Integreat cms for the use case of coldaid
Apache License 2.0
4 stars 0 forks source link

Add CORS headers for API #32

Closed timobrembeck closed 4 years ago

timobrembeck commented 4 years ago

Currently, the App cannot query our API correctly because the cms is lacking the correct CORS headers. I propose to use a plugin for this: https://pypi.org/project/django-cors-headers/

Please add this to the dependencies and configure the minimal settings.

Alternatively, you can modify the relevant API endpoints by the following code snippet:

response = JsonResponse(result, safe=False)  # Turn off Safe-Mode to allow serializing arrays
response["Access-Control-Allow-Origin"] = "http://localhost:3000"
response["Access-Control-Allow-Headers"] = "*"
return response
timobrembeck commented 4 years ago

Was fixed by @Stani-tar in 819fe8f8f3a8bf6e0b2e86cb0d22fdfa014219b2.