I am prety sick already with inability to just embed a youtube video by url provided from database.
I have whitelisted youtube by
app.config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist([
'self',
'https://www.youtube.com/**'
]);
})
Then in controller I fetch video data from server (database) and use $sce
to set url to be truested
app.controller('videosCtrl', ['$scope', '$http', '$sce', function($scope, $http, $sce) {
$scope.video = null;
$scope.video_url = null;
$http.get('/side/video').success(function(data) {
if(data.length > 0) {
$scope.video = data[0];
$scope.video_url = $sce.trustAsResourceUrl(data[0].url);
}
});
}]);
then I render iframe
by (jade)
iframe(ng-src="{{video_url2}}",width="100%",height="300",frameborder="0",allowfullscreen)
And in result in chrome dev console I get
Refused to display 'https://www.youtube.com/watch?v=WN66EpVdxsk' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
What else should I do to convince angular that it's ok to render videos from youtube?!
SOLUTION: I have found that /watch
refuses to stream videos from different origin, but www.youtube.com/embed/
allowes, so I just extracted video id from first url and added it to the second.