I can't make a DELETE with CORS and AngularJS

2019-09-07 20:43发布

问题:

I'm trying to make a DELETE request with AngularJS.

I'm sending this headers from the Server:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: origin, x-requested-with, content-type, accept');
header('Access-Control-Allow-Method: GET, POST, OPTIONS, DELETE');

But in Chrome, when I do an

$http({method: 'DELETE', url: EmployeesURL + "remove/id/" + id}) 

it throws a Method DELETE is not allowed by Access-Control-Allow-Methods. error.

回答1:

Looks like you are missing an 's' Access-Control-Allow-Methods