ibm-mobilefirstworklight-adaptersworklight-server

Cross Domain Error Worklight Adapter Request


I'm trying to make a GET request from an iPhone app(built on Worklight), to a remote worklight adapter on a remote server. I have generated the authorization request header using the following

http://remote-url:port/project/authorization/v1/testtoken

However, I keep getting the following cross domain error:

XMLHttpRequest cannot load https://remote-url/project/adapters/call/mq/getAccounts/22. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://myapp-url:port' is therefore not allowed access.

But, when I try do the same GET request using an API tool like Postman, I receive the results no issues on my browser.


Solution

  • First - testtoken is only available from the MobileFirst Studio development environment... you need to take this into consideration.

    Second, you're likely using Chrome and Crome disallows CORS by default. Change your browser settings and/or try in a different browser.