Django Rest Framework Endpoint Request Fails with Error Cross-Origin Request Blocked

I have a django rest application back end with an angular front end. All the endpoints work perfectly locally but when I deploy it to google cloud all endpoints works except one which keeps on displaying the error Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at url (Reason: CORS request did not succeed). I have tried to connect the database on the cloud with the local application, all the endpoints requests are displayed on the IDE console except the one, and the browser displays the request is not yet finished. Any ideas on what is causing the issue will be highly appreciated

Install Django-cors-headers to solve this problem Follow this link: https://pypi.org/project/django-cors-headers/

  1. python -m pip install django-cors-headers
  2. INSTALLED_APPS = [ ..., "corsheaders", ..., ] add middleware top of the commonmiddle
  3. MIDDLEWARE = [ ..., "corsheaders.middleware.CorsMiddleware", "django.middleware.common.CommonMiddleware", ..., ]
Back to Top