Why does Glitch block resources from other URL?

Hello, so I need to look into livestreams and i found about hls.js library which actually has a glitch but right now its just showing the animated bunny video. i wanna test it with a live livestream and i found a youtube one but when i try it out i get : Access to XMLHttpRequest at ‘https://www.youtube.com/embed/j7x55c2-79c’ from origin ‘https://natural-pastoral-memory.glitch.me’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

It is not blocked by Glitch, instead the resource you are trying to use has a header which prevents the resource from being used by websites from other origins (meaning domain). The resource can only accessed from the same domain and not from other domains. You cannot do anything on your end to solve this issue as YouTube needs to prevent cross origin requests to their sites. Or you could use a proxy.

2 Likes

@khalby786 is correct but you should be very careful is you decide to set up a “CORS Anywhere” or proxy website as these go against Amazon Web Services policy. Glitch has taken these type of websites down due to this rule.

2 Likes

You can use existing proxies, as I do not think they violate any rules.

My proxy got taken down (remixed from the proxy cheif proxy)

chief.riverside.rocks

(I have a feeling that SKM = proxy)

1 Like

You can add this in your express server:

app.use((req, res, next) => {
  res.set("Access-Control-Allow-Origin", "*");
  next();
});

This should be above all other routes.

Ah i see. Any live livestreams i could use to test out?

You can try one of the ones on this page: https://youtube.com/live

2 Likes