FAQ  •  Register  •  Login

[CDS API] XmlHttpRequest from a not allowed IP

<<

kissskoool

Streaming enthusiast

Posts: 25

Joined: Mon Aug 05, 2013 1:15 pm

Post Tue Aug 06, 2013 2:54 pm

[CDS API] XmlHttpRequest from a not allowed IP

Hi,

After my two first posts, i still have some questions, but i'm sure it will be useful for others too ;)

I'm trying to make a JS XmlHttpRequest like this :

  Code:
function cds_info(token, object_id){
   var xhr = new XMLHttpRequest();
   xhr.open("GET", "http://my_server_ip:23424/cds/browse/flv_player/"+object_id+"/BrowseMetadata/all/0/1?authToken="+token);
   xhr.setRequestHeader("Accept", "application/xml | application/json");
   xhr.onreadystatechange = function () {
     if (this.readyState == 4) {
      alert('Object_id: '+object_id+'\nStatus: '+this.status+'\nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'\nBody: '+this.responseText);
     }
   };
   xhr.send(null);
}


And i get this error message :

Origin http://my_server_ip is not allowed by Access-Control-Allow-Origin

How can i allow this request ?

Many thanks for your help !
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Aug 06, 2013 5:32 pm

Re: [CDS API] XmlHttpRequest from a not allowed IP

The accept-type is either application/xml or application/json. The API shows that in not so clean way, sorry about that.

It'll define if you get back XML or JSON, the choice is yours.
<<

kissskoool

Streaming enthusiast

Posts: 25

Joined: Mon Aug 05, 2013 1:15 pm

Post Tue Aug 06, 2013 6:04 pm

Re: [CDS API] XmlHttpRequest from a not allowed IP

Thanks for your answer.
It was not exactly what i asked but it doesn't matter i found a solution for the Access-Control-Allow-Origin problem due to cross domain ajax limits.

i just did a reverse proxy to redirect http://my_server:23424/cds/... to http://my_server/cds/... so i remain on the same domain.
<<

ailete

Serviio newbie

Posts: 1

Joined: Sun Aug 11, 2013 2:19 pm

Post Sun Aug 11, 2013 2:21 pm

Re: [CDS API] XmlHttpRequest from a not allowed IP

Hi kissskoool !

I encountered the same issue, but I did'nt manage to resolve it yet.
You say you found a solution by setting a reverse proxy... Can you explain how you did it please ? It would be really helpful for me.

Thanks a lot :D
<<

kissskoool

Streaming enthusiast

Posts: 25

Joined: Mon Aug 05, 2013 1:15 pm

Post Mon Aug 12, 2013 12:25 pm

Re: [CDS API] XmlHttpRequest from a not allowed IP

Access-Control-Allow-Origin problems is due to a cross ajax request from a domain to another one.
The origin url and the destination url must have the same domain and port.

So http://my_server:23424/cds/ and http://my_server/cds/ are considered two different domains.

My solution is to redirect on my server http://my_server:23424/cds/ to http://my_server/cds/

To do that you have to activate mods proxy and proxy_http

then in your site apache virtualhost you'll have to add those lines :

  Code:
   
<Location /cds>
        ProxyPass http://127.0.0.1:23424/cds
        ProxyPassReverse http://127.0.0.1:23424/cds
    </Location>

Return to Third-party tools integration

Who is online

Users browsing this forum: No registered users and 20 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.