0

I am trying to invoke wordpress rest api's in ionic application most api's seem to work fine but while invoking some api's mostly the setter api's i get the CORS error however they work perfectly when invoked via web. Most of the solutions available online are for localhost but since i need to implement the same on online resources they are not useful unable to get any clue about the rectification also since some api may involve limited access i can not prefer any third party proxy sites.the error i am getting is as follows:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://test.oiamigotech.com/api/user/generate_auth_cookie/?username=dsfsdfdsdfssdf&password=sdfsdfsdfsdf&insecure=cool. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

3
  • You have to all header via php Commented Aug 10, 2017 at 7:53
  • Ionic have its own proxy. Give it a try Commented Aug 11, 2017 at 2:23
  • please explain how can i use the ionic proxies ?? Commented Aug 11, 2017 at 6:08

1 Answer 1

0

I managed to resolve the following issue by adding a header to allow cross origin request in the header of the api file of the plug-in as indicated in this Stackoverflow link.

All I had to do is to add the following to the header of api code

header( 'Access-Control-Allow-Origin: *' );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.