Kodkollektivet / unitime-api

Unitime Rest API
http://api.kodkollektivet.se/unitime/
8 stars 2 forks source link

Cross-Origin Requests are blocked #11

Open ritzelpaket opened 6 years ago

ritzelpaket commented 6 years ago

Browser console logs: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.kodkollektivet.se/api/event/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

If the application runs on the same domain, the error possibly won't show. But on a development machine or different domain you actually can't call the API without enabling CORS globally in the browser.

Same for other resources like /course.

ritzelpaket commented 6 years ago

Could someone fix this please?

jhe10709 commented 6 years ago

I can have a look at it as soon as possible, i guess today. What do you think about this? https://github.com/ottoyiu/django-cors-headers

ritzelpaket commented 6 years ago

I just flew over.. but it seems to be the right thing. I had a similar problem in Node. A Middleware was also the solution.

jherrlin commented 6 years ago

This commit may resolve the issue: https://github.com/Kodkollektivet/unitime-api/commit/a76b7f2a8ffed9b12db60d68cf64cffebff40b3c