3

I was trying to implement a simple player with a web server on a VM when I stumbled across this issue.

server.js

const express = require('express'); 
var app = express();
var path = __dirname + '/views/' ;
app.get("/",function(req,res,next){
  res.sendFile(path + "index.html");
});
app.listen(1823);
console.log('listening');

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Alpha</title>
  </head>
  <body>
    <iframe id="player" width="640" height="360" src="http://www.youtube.com/embed/N0dbGGvsjf8?enablejsapi=1&origin=http://192.168.150.129">
    </iframe>
  </body>
</html>

Accessing the site locally with http://localhost:1823 works just fine. However, accessing the site from the local network such as http://192.168.150.129:1823 the iframe(?) stops working.

Screenshot

Same video works on JSFiddle.

NB: This only happens on certain videos.

e.g. with this iframe

<iframe id="player" type="text/html" width="640" height="360" src="http://www.youtube.com/embed/PfYnvDL0Qcw?enablejsapi=1&origin=http://192.168.150.129">
</iframe>

Both localhost and IP work the same.

All seems to point towards Node doing something? Why some videos work and others do not?

Joshelin
  • 31
  • 8
  • YouTube is detecting that it is being loaded in an iframe and it's blocking the content. And localhost may get different treatment than a normal IP. Here's another similar question you might have a look at: https://stackoverflow.com/questions/8698742/getting-youtube-com-to-load-in-iframe Good luck! – Todd Price Nov 16 '18 at 03:04
  • 1
    Nice suggestion but that's not the case. Unfortunately this issue happens only with 'popular' videos, such as "Hey Jude" or "Bohemian Rhapsody" etc. I also thought about the Firewall, I tried allowing anything from anything to anything and yet the issue was still there. – Joshelin Nov 17 '18 at 20:55
  • I faced the same problem. @Joshelin do you have something to find out? Looks like it is about **origin** and **cookies**... – Zakhar Skorokhodov Oct 24 '19 at 19:40
  • I'm sorry but no. Would be nice to find an answer after turning in my project and actually getting full marks with this bug still present. – Joshelin Oct 15 '20 at 22:29

0 Answers0