2017-04-26 17 views
0

でユーチューブビデオ結果を埋め込む:は、私は私のイオンアプリで動画を埋め込むしようとしているが、ページがロードされるとエラーが現れるCORSエラー

GET https://redirector.googlevideo.com/videoplayback?pcm2cms=yes&key=yt6&ei=5HE…QBGK&c=WEB&cver=1.20170425&cmo=pf=1&range=0-622&rn=15&playerretry=3&rbuf=0 404 (Not Found) 

XMLHttpRequest cannot load https://redirector.googlevideo.com/videoplayback?pcm2cms=yes&key=yt6&ei=5HE…QBGK&c=WEB&cver=1.20170425&cmo=pf=1&range=0-622&rn=15&playerretry=3&rbuf=0. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.youtube.com' is therefore not allowed access. The response had HTTP status code 404. 

ここに私のhtmlコードは次のとおりです。

<iframe width="420" height="315" src="{{video}}" ></iframe> 
ここ

はcontroller.jsコードです:

$scope.video = "https://www.youtube.com/embed/RP-mvJE9EQM"; 

私は私のapp.jsファイルでこれを追加しました:

$sceDelegateProvider.resourceUrlWhitelist(['self', new RegExp('^(http[s]?):\/\/(w{3}.)?youtube\.com/.+$')]); 

と、この私のconfig.xmlファイル内:

<allow-navigation href="*.youtube.com" /> 
<preference name="AllowInlineMediaPlayback" value="true" /> 

は、どのように私はこれを解決するについて行くべきですか?私は何かが欠けていますか?

答えて

0

httpsではなくhttpで試してください。 はまた、それがすべてを可能にするので、あなたはそれを使用している場合は注意してくださいindex.htmlを

<head> 
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: 'unsafe-inline'; connect-src * 'unsafe-inline'; frame-src *;"> 
</head> 

内のこの行を入れてみてください。コンテンツセキュリティポリシーに関する 詳細情報:

https://developers.google.com/web/fundamentals/security/csp/

この情報がお役に立てば幸いです。

+0

感謝を。私はindex.htmlでコード行を追加し、httpを使用していますが、それはまだ動作していません。 –

0

私が追加:

<access origin="*" /> 

をconfig.xmlに入力に対する