Sending request as OPTIONS instead of POST,GET in backend

I am using Spring boot as a back end. When ever i try to hit the API using HTTP client, the requests are sending using OPTIONS instead of POST,GET. And also in front end i am getting the below CORS error.

Access to XMLHttpRequest at 'https://..........' from origin 'http://localhost:8100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

Can anyone help me with this.

Thanks in advance.

This is very common error.
You need to allow cross-origin request from server side. Also need to allow headers (if you are passing custom headers to HTTP request).

1 Like

@niravparsana94 Thanks for the reply.
In backend we are just adding @CrossOrigin for every class isn’t it sufficient??

I can’t tell you exact configuration for your programming language. Better you can google it yourself.

1 Like

@lohith95 if you find solution working, then mark it as answer so that question can be closed.

Is there any way to handle it from ionic end??

No, i guess. You can’t control things restricted at server-side from client-end.

1 Like