New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORS problem with Nginx, Tomcat, and Shaka #633
Comments
This is most likely a CORS (Cross-Origin Resource Sharing) error. If you open the JS console, you should see some message about that from the browser. Here's where you can read more about CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS In short, when your page is hosted on one domain, and your resources are hosted on another, the server must supply special headers in the response. If it does not, the browser will deny access to that resource. |
Thanks for your answer, @joeyparrish. So, can i could solde this problem? |
Yes, by adding the required headers on your server. Note that this is not a Shaka-specific requirement. This is something built into all modern browsers to prevent cross-site attacks. For example, our demo content is meant to be accessed by anyone from any domain. To achieve this, we serve the content (both manifest & media) with these HTTP headers:
|
Thanks, @joeyparrish. So do i have to configure tomcat backend for adding the following HTTP response header?
How could i insert these header in HTTP response in tomcat container? Based on official docker tomcat image. |
Sorry, I'm here to support Shaka Player, not Tomcat or any other web server. You will have to refer to Tomcat documentation to learn how to configure it. I couldn't possibly keep up with every web server, and it would be more efficient for you to read the docs for yourself. |
Thanks for your support, @joeyparrish |
Hi everyone, i'll explain you my problem. With reference to #628 (comment), i've created an .mp4 segmentated and crypted video using Shaka Packager. All these contents are provided by a Tomcat Container, on port 8080.
When i browse with http://localhost:8080/shaka-player-master/demo/index1.html (browser Firefox 50.1.0, Chrome Version 55.0.2883.75 (64-bit)), it plays correctly my content.
In fact, with the following snippet
reproduces correctly contents.
-The first problem occurs when i replace
" manifestUri: '//localhost:8080/shaka-player-master/media/example-av.mpd', // gjslint: disable=110"
with " manifestUri: '//:172.17.0.18080/shaka-player-master/media/example-av.mpd', // gjslint: disable=110" ,
where 172.17.0.1 is the default docker0 interface. Browser can't reproduce content, and show the following error:
Shaka Error NETWORK.HTTP_ERROR (http://172.17.0.1:8080/shaka-player-master/media/example-av.mpd)
Here there's console log:
Player error Object { category: 1, code: 1002, data: Array[1], message: "Shaka Error NETWORK.HTTP_ERROR (htt…", stack: "shaka.util.Error@http://172.17.0.1:…" } main.js:199:3
shakaDemo.onError_ http://172.17.0.1:8080/shaka-player-master/demo/main.js:199:3
shakaDemo.load/< http://172.17.0.1:8080/shaka-player-master/demo/asset_section.js:189:7
This is my first problem, i don't know why there is this error, in fact GET /path/example-av.mpd returns 200 OK.
-Second problem occurs in this case: i want using an nginx container as proxy cache (on port 9000 host-->80 container): here is /etc/nginx/conf.d/default.conf configuration file:
In few world, then i browse 172.17.0.1:9000/demo/, it will redirect, in case of cache MISS (the first time), to http://172.17.0.1:8080/shaka-player-master/demo/index1.html ... so it will reproduces content i choose. Note that in index1.html there is a js (assets.js, see here with the same form of the previous snippet:
The result is.. there is the same error of problem #1!
Shaka Error NETWORK.HTTP_ERROR (http://172.17.0.1:8080/shaka-player-master/media/example-av.mpd)
Player error Object { category: 1, code: 1002, data: Array[1], message: "Shaka Error NETWORK.HTTP_ERROR (htt…", stack: "shaka.util.Error@http://172.17.0.1:…" } main.js:199:3
shakaDemo.onError_ http://172.17.0.1:8080/shaka-player-master/demo/main.js:199:3
shakaDemo.load/< http://172.17.0.1:8080/shaka-player-master/demo/asset_section.js:189:7
Also here there is a strange behaviour. When i browse localhost:9000/demo/ --> /path/to/page/index1.html, if index1.html download a js from here (line 381) the browser can reproduces default demo contents.
So there is a problem when i try to use nginx cache--> html in tomcat backend-->js that GET an mpd created by myself (with shaka-packager). But then i browse directly content from tomcat in browser, it will work (see problem #1).
I'm sorry for the long and detailed question. Can someone help me?
The text was updated successfully, but these errors were encountered: