By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 1,984 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

(Reason: CORS request did not succeed) DRF and Angular

100+
P: 228
Hi,

We have a DRF backend API and two front-end applications: a CRUD and a report server. Currently, we have issue with CORS:

These are the domains:

sever.com:8098 == >backend

and front ends:

crud.com
reporter.com

==

backend settings.py is:



Expand|Select|Wrap|Line Numbers
  1.  
  2. DEBUG = False
  3.  
  4.  
  5. ALLOWED_HOSTS = ['crud.com', 'reporter.com',]
  6.  
  7. CORS_ORIGIN_ALLOW_ALL = False # dont want that.
  8.  
  9. CORS_ALLOW_CREDENTIALS = False # we use no cookies
  10.  
  11. CORS_ORIGIN_WHITELIST = (
  12.  
  13.     'reporter.com',
  14.     'crud.com',
  15.  
  16. )
  17.  
  18. CORS_ALLOW_METHODS = (
  19.     'DELETE',
  20.     'GET',
  21.     'OPTIONS',
  22.     'PATCH',
  23.     'POST',
  24.     'PUT',
  25. )
  26.  
  27.  
  28. CSRF_TRUSTED_ORIGINS = (
  29.     'crud.com',
  30.     'reporter.com'
  31.  
  32. )
  33.  
  34. CORS_ALLOW_HEADERS = (
  35.     'accept',
  36.     'accept-encoding',
  37.     'authorization',
  38.     'content-type',
  39.     'dnt',
  40.     'origin',
  41.     'user-agent',
  42.     'language',
  43.     'x-requested-with',
  44. )

But I still get CORS blocked error. What am I missing? Note that I have custom header but the front-end submits it successfully so not sure where it lies.
Jan 9 '19 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.