Django CORS因移动应用程序的发布请求而失败

时间:2017-09-22 08:53:02

标签: python django angular django-cors-headers

  • 我正在使用Angular 4 / Ionic 3作为前端/移动应用。
  • 我正在使用Django 1.11 for the backend

当我尝试从浏览器发送请求时:
headers.append('Content-Type', 'application/json');
headers.append('Access-Control-Allow-Origin', '*');
this.http.post('http://0.0.0.0:8000/en/accounts/user/', {} , {headers:headers})

在我的Django应用程序中,我使用了django-cors-headers并设置:
  - CORS_ORIGIN_ALLOW_ALL = True
  - CORS_ALLOW_CREDENTIALS = True

从浏览器中我得到了预期的响应,但是当从移动应用程序测试时,CORS请求似乎没有通过(返回Response with status: 0 for URL: null

 Here are the request headers when i click to send request 对此有何建议?

1 个答案:

答案 0 :(得分:0)

伙计我猜今天我很愚蠢或周五我不知道,但问题是网址可能是Mariusz& Nrzonline建议。

我改变了:
this.http.post('http://0.0.0.0:8000/en/accounts/user/', {} ,this.http.post('http://192.168.178.2:8000/en/accounts/user/', {} ,

现在它起到了魅力。

相关问题