CORS Origin null from STA SDK 3.0 ?

CORS Origin null from STA SDK 3.0 ?

Postby rob.1_1 » Fri Aug 01, 2014 3:09 am

When I try to use the following code from the sdk 3.0 emulator I get a 405 - Method Not Allowed, because XmlHttpRequest cannot load my URL - Origin Null not allowed by Access-Control-Allow-Origin ... CORS is working with identical code on other platforms , is it perhaps because the browser in the emulator treats application script domain as file:// (and sets to null) rather than localhost:// ?

I feel I must be missing something, or everyone would have the same issue ?

--------------------
function postToURL(url, process,data){

if (XHRObj !== null) {
XHRObj.destroy();

}
XHRObj = new XMLHttpRequest();

if (XHRObj)
{
console.log(\"setting up POST\");


if (XHRObj.overrideMimeType)
{
XHRObj.overrideMimeType('text/plain');
}

XHRObj.withCredentials = true;

XHRObj.open(\"POST\", url, true);

Process = process;

XHRObj.onreadystatechange = readyStateChanged;

console.log(\"object opened - \" + url);

var auth = window.btoa(LoggedInUser + \":\" + LoggedInPassword);

console.log(\"credentials encoded\");
console.log(\"Auth header is \" + auth);

XHRObj.setRequestHeader(\"Authorization\", \"Basic \" + auth);
// XHRObj.setRequestHeader(\"Access-Control-Allow-Origin\",'*');
XHRObj.setRequestHeader(\"Content-Type\", \"application/json; charset=utf-8\");

console.log(\"request header set\");

XHRObj.send(data);
}


console.log(\"XHR request processed , readyState is \" + XHRObj.readyState);
}
--------------------
rob.1_1
 
Posts: 3
Joined: Mon Jul 27, 2015 5:03 am

CORS Origin null from STA SDK 3.0 ?

Postby Support_STA » Sun Aug 03, 2014 6:41 pm

Hi,

Did you try to load a html file from your source? (In case,we have not tried before, but we think load() function of Jquery would be better).
Besides, hope this documentwill be helpful for you.

Regards,
STA Support
Support_STA
 
Posts: 136
Joined: Fri Aug 09, 2013 3:56 am

CORS Origin null from STA SDK 3.0 ?

Postby rob.1_1 » Mon Aug 04, 2014 2:10 am

If you look at the code I posted (which is from index.html of the app) you'll see I am posting an xmlhttprequest to a url and expecting a JSON response ... the server has CORS support and should be returning the correct response headers ...
rob.1_1
 
Posts: 3
Joined: Mon Jul 27, 2015 5:03 am

CORS Origin null from STA SDK 3.0 ?

Postby Support_STA » Mon Aug 04, 2014 7:21 pm

Hi,

As you mentioned, emulator treats application as file:// not localhost://.
So doing ajax from file URL isinconsistently, e.g: Chromeentirely disallows them.
For solution, you can upload your source to a server or using your staging server to check it with emulator.

Regards,
STA Support
Support_STA
 
Posts: 136
Joined: Fri Aug 09, 2013 3:56 am

CORS Origin null from STA SDK 3.0 ?

Postby rob.1_1 » Tue Aug 05, 2014 9:32 am

It's disappointing, when you consider the LG webOS TV emulator and the Samsung SMART TV emulator, both based on VirtualBox images can do it ... is there no way to turn off checking by the browser JUST in the emulator image (Chrome can do -ignore-security-settings) ?
rob.1_1
 
Posts: 3
Joined: Mon Jul 27, 2015 5:03 am


Return to App development questions



cron