Re: 401 Unauthorized with Hello-world example

Follow

Originally posted by support@cumulocity.com on 2013-04-24 21:06:14

Hi Hervé,

it seems you are having an issue with the same origin policy of your browser, see http://en.wikipedia.org/wiki/Same_origin_policy">http://en.wikipedia.org/wiki/Same_origin_policy. That policy enforces that REST requests issued from a web page can only go to the same server that the web page came from.

If you are developing on your PC, your web page is coming from localhost, whereas the request goes to developer.cumulocity.com. So the browser will reject the request.

To still be able to develop on your PC, you have three options.
* Put your browser into development mode. You can launch Chrome with the argument "–disable-web-security".
* Use the Eclipse SDK. The SDK comes with a proxy servlet that passes everything send to localhost/apis to the Cumulocity server. This is described in "Run the application" in the "Hello, world!" example.
* If you don't use Eclipse or the SDK, use another proxy. There are some available. One of our developers uses a Grunt task for this.

What we have currently on the roadmap is support for CORS (http://de.wikipedia.org/wiki/Cross-Origin_Resource_Sharing">http://de.wikipedia.org/wiki/Cross-Orig … ce_Sharing), which will allow you to simply develop without any of the above workarounds by configuring your tenant to allow CORS to you.

Maybe the above discussion deserve a section in the docs … :-/

Cheers,
André
Have more questions? Submit a request

Comments