this problem occurs when we make custom header for request.This request that uses the HTTP OPTIONS
and includes several headers.
The required header for this request is Access-Control-Request-Headers
, which should be part of response header and should allow request from all the origin. Sometimes it needs Content-Type
as well in header of response. So your response header should be like that -
response.header("Access-Control-Allow-Origin", "*"); // allow request from all origin
response.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
response.header("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Origin, X-Requested-With, Content-Type, Accept, Authorization");