473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

228 100+
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
0 2205

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

Similar topics

0
by: knguyen | last post by:
Hi, For some reason, httplib request() method splits the request packet into two packets, the first packet contains only HTTP headers, the body in the second packet. The first packet size is way...
8
by: turnit \(removethis\) | last post by:
I have a login form that uses the post method to carry the information to the next page. The form works just fine in ie6.0, but fails in mozilla and fails in ie5.2 on a mac. "HTTP/1.1 400 Bad...
2
by: Sean Dotson | last post by:
I have a form that passes variables to an asp file and then uploads a file. For some reason the request.form is not getting the info from the form. It's returning blanks. Any insight would be...
4
by: norton | last post by:
Hi all. I have a question in using Request and Request.Form when the asp page is Request("txtName") i can use "testpage.aspx?txtName=User1" to post the value but when i use...
0
by: GarciaPL | last post by:
Hi, I have this well-known issue with Access-Control-Allow-Origin in my Spring application. I use cross-domain request to read data from built in MongoDB database REST interface (for example :...
1
by: tdrsam | last post by:
I'm trying to set a list of two items that open separate modal dialogs in a node.js app. I'm using Jade. Here's the Jade: button.login-button(type='button' ng-app='ng-modal') Login ul ...
1
by: samvb | last post by:
Hey Fellas, I am seriously in despair. I have a CI driven app in domaina.com. I need to send cross domain request to a SINGLE controller in it from domainb.com. It will be an ajax call using POST...
0
by: khaledbelal | last post by:
When i post form angular form to API Laravel i get error 500 (Internal Server Error) in console .... why? Note: Backend API is working perfectly with POSTMAN. My Cors.php in Laravel is: ...
5
by: Palaksinghla | last post by:
Angular, is the most popular javascript framework. The self proclaimed Super heroic framework is gaining a lot of traction from professionals over the globe. With features like less coding and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.