Always got Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response

前端 未结 2 1146
执念已碎
执念已碎 2020-12-31 01:04

I am using jersey as my restful api implementation. In the front end, I am using angularjs $http service to make http request. When I request a delete method I always got be

2条回答
  •  温柔的废话
    2020-12-31 01:39

    After some testing, I found the solution. I put the allow method on the header as below, then it works. I don't know why "*" doesn't work.

    headers.add("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE");
    

提交回复
热议问题