When I use put or delete, it turns into OPTIONS. I am using expressjs for my server framework.
Client:
$http({
method: 'DELETE',
url: HTTP_URL + '/update/account',
params: { mail: mail }
});
Server:
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Credentials", true);
res.header('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE');
res.header("Access-Control-Allow-Headers",
'Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept');
next();
});
The browser is automatically sending the CORS pre-flight OPTIONS request; this is correct behavior and you can't avoid it. If the server allows the origin, method, etc., then the browser will follow up with the DELETE request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With