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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


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

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

Highlighted
Developer
Posts: 1,230
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!