If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Visitor
dulli
Posts: 1
Registered: ‎12-15-2012
My Device: WebWorks - PlayBook & BB10
My Carrier: none

setRequestHeader and Access-Control-Allow-Origin errors with BB10 Gold Simulator

[ Edited ]

While porting my app from WebWorks for PlayBook to BlackBerry 10 using the Gold SDK I came across two errors regarding XHR requests which are unfortunately breaking my app.

 

Firstly while trying to send cross domain requests the WebInspector gives me the following error:

Origin local:// is not allowed by Access-Control-Allow-Origin.

I have declared this in the config.xml:

<access uri="*"/>

 

 

The second error I encountered, which could of course be due to the requests not being send properly, is the fact that

req.setRequestHeader()

 doesn't seem to do anything at all. I don't get any error message but it also does not add any headers to the request. I am using it to add HTTP basic authentication to the requests:

 

var auth = window.btoa(this.user+':'+this.passwd);
req.setRequestHeader('Authorization', 'Basic '+auth);

 

I am trying this using the simulator, it all works fine using ripple with disabled SOP. The same codebase also worked fine on the PlayBook. Unfortunately I don't have any real BB10 device to test my app on yet.

 

I also can't change anything about the server I am sending to, so the Authorization header is required for my app to work

Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: setRequestHeader and Access-Control-Allow-Origin errors with BB10 Gold Simulator

I've written quite a lot about this in the last few days

 

Please see this and this

 

I'm not sure about your auth stuff as I never use it for server requests

 

Basically my posts point you at some tested source that defo works

 

The other thing to do is test using the simulator

 

I go into the problem quite deeply so the other posts are worth a read

 

Can't be positive my stuff will fix you but it's solved other peoples problems




Click the like button if you find my posts useful!
Please use plain text.