I have an Angular (v1.13.15) application and Express.js (v4.12.4) as a backend.
I have a DELETE method in my backend and I have enabled CORS support.
But when I use Angular $ http.delete, I encounter this error
No header "Access-Control-Allow-Origin" is present on the requested resource.
I tried using jQuery, $ .ajax () for this, and I get the same problem!
I also tried using POSTMAN to execute a DELETE request, and there is no problem.
But I have no problem using my Angular for my GET and POST method.
Can I find out what the problem is?
My backend address is
http: // localhost: 3000
I serve my AngularJS with gulp -webserver
http: // localhost: 8000
My server code
exports.deleteGPSData = (req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.header('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
let id = req.params.id;
res.send('here');
}
Angular
$http.delete(API_URL + '/gps/' + id)
.success(function(res) {
if (res.result !== 1) {
return defer.reject(new Error(id + ' failed to delete'));
}
defer.resolve(res.id);
})
.error(function(status) {
defer.reject(status);
});
GET POST! DELETE, CORS!
Google Chrome

Postman,
