Old 1st November 2016, 22:27   #1
Phixxy
Junior Member
 
Join Date: Nov 2016
Posts: 4
Changing HTTP Headers/HTTP access control/CORS

Hello I have a shoutcast server set up on my linux machine and I have a website that links users to the stream. On my website I want to pull json data from the statistics?json=1 page. However when I try to do this I get an access control error: XMLHttpRequest cannot load http://192.168.1.1:8000/statistics?json=1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.example.com' is therefore not allowed access. (IP and website name changed for privacy reasons.) I know I need to add an Access-Control-Allow-Origin header to the json page and I have tried my hardest to find out how to do so, but with no luck. If this is possible please help me out I would really appreciate it.
Phixxy is offline   Reply With Quote
Old 2nd November 2016, 03:47   #2
jaromanda
Forum King
 
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,289
much easier to get the data with your server - have you looked in the documentation that comes with DNAS server to see if there's any mention of such headers?

Is it just me or are shoutcast users getting dumber?
jaromanda is offline   Reply With Quote
Old 2nd November 2016, 20:11   #3
Phixxy
Junior Member
 
Join Date: Nov 2016
Posts: 4
I've searched through the documentation looking for "http-headers", "CORS", and "Access-Control-Allow-Origin". I could not find anything mentioning it.
EDIT: I guess I could host an apache server on the same server, pull the json and add the header to the apache server but this seems overkill for what I am trying to do.
Phixxy is offline   Reply With Quote
Old 2nd November 2016, 21:29   #4
jaromanda
Forum King
 
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,289
Hmmm, seems shoutcast in there wisdom has made provisions for flash player crossdomain access, but fell short for browser crossdomain access

P.S. you don't need to host apache on the same server as DNAS - you have a website, correct? so you already have a server, correct? so use that server to "proxy" requests for DNAS - crossdomain rules are browser security feature. Servers should have no problem getting the info from DNAS

Is it just me or are shoutcast users getting dumber?
jaromanda is offline   Reply With Quote
Old 2nd November 2016, 23:07   #5
Phixxy
Junior Member
 
Join Date: Nov 2016
Posts: 4
I don't know how to proxy requests from my web server. I don't know if that would even work because the two servers are separate.
Phixxy is offline   Reply With Quote
Old 3rd November 2016, 23:17   #6
jaromanda
Forum King
 
Join Date: Jun 2007
Location: Under the bridge
Posts: 2,289
that's what proxying is all about - besides, apache on the same server as DNAS would still be a different origin (because the port number HAS to be different for apache than for DNAS) so, it's the same process regardless of where the "regular" http server is

Is it just me or are shoutcast users getting dumber?
jaromanda is offline   Reply With Quote
Old 4th November 2016, 01:15   #7
Phixxy
Junior Member
 
Join Date: Nov 2016
Posts: 4
Well then I guess I went with the best option. What I ended up doing was creating a python script to pull the raw html and upload that as a file to the server every 10 seconds. It isn't the best way but it will at least work.
Phixxy is offline   Reply With Quote
Old 6th November 2016, 15:31   #8
neralex
Major Dude
 
Join Date: Mar 2011
Posts: 576
I don't understand the issue. Do you have your web-server and your DNS-server in a local network without access from outside? If your server (where the DNAS is running) is available via Internet from outside of your local network (192.168.1.1 is a local network IP), then you can grab the json-data from the public IP without a issue.
neralex is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump