I want to make a call to Youtube from a web app hosted on my local machine. That results in a CORS error:
localhost/:1 Access to fetch at 'https://www.youtube.com/watch?v=<id>' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
To get around this, I want to use a proxy server to call Youtube on my behalf. https://github.com/Rob--W/cors-anywhere/tree/master seems like a quick way to do this.
First, I went to https://cors-anywhere.herokuapp.com/corsdemo to request temporary access. Next, I need to structure the Youtube call used in my webapp to make calls via the proxy server.
When I try https://cors-anywhere.herokuapp.com/www.youtube.com on my browser, I get the error: Missing required request header. Must specify one of: origin,x-requested-with
So then I try https://cors-anywhere.herokuapp.com/origin=http://localhost:3000/www.youtube.com I get the error Invalid host: origin
What's the right way to structure this call?