5

I have a hls stream that is downloaded from server. I then create a local webserver using this library ! I successfully ran the server and I can play the content from a VLC player on my PC .However it fails on JW player and Google Chromecast due to CORS issue. The possible solutions I found is to put a .htaccess file / crossdomain.xml file in the folder my server runs from . Is there a way to programatically set the headers of NanoHttpd to allow CORS ? This I am using to locally serve files to the google Chromecast

Sidhanth Sur
  • 303
  • 2
  • 9

1 Answers1

3
  resp= newFixedLengthResponse(Response.Status.OK, MIME_PLAINTEXT ,"success");
            resp.addHeader("Access-Control-Allow-Origin", "*");
            resp.addHeader("Access-Control-Max-Age", "3628800");
            resp.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, OPTIONS");
            resp.addHeader("Access-Control-Allow-Headers", "X-Requested-With");
            resp.addHeader("Access-Control-Allow-Headers", "Authorization");




            resp.setChunkedTransfer(true);
return resp;

You can do like this.

Mahesh Giri
  • 1,810
  • 19
  • 27