0

Http.Delete doesn't working on angular 5.2.0

The Code is:

let headers = new HttpHeaders({ 'Content-Type': 'application/json' });
this.http.delete(this.url + encodeURIComponent(key.id), {headers : headers})
                           .toPromise();

The error message is: Failed to load http://localhost/project/bfd19ece-f4a1-4935-ae3f-d5ea28969871: Response for preflight has invalid HTTP status code 403

enter image description here

Edit: The delete is working using fiddler composer

Edit: The problem is solved by open chrome by run this

chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security

From this link: Here

Thanks in advance.

neo-ray
  • 9
  • 1
  • 11

1 Answers1

0

This is not a problem with angular, it's that the OPTIONS request made by angular (to find out whether it can do a cross domain request) is failing with a 403.

Your origin is different to the requested URL so it needs to check that it's allowed to make the request.

This SO post may help

Scott Perham
  • 2,410
  • 1
  • 10
  • 20