Proxy video from Google Cloud Storage
I'm using the REST API for GCP Cloud Storage to fetch JSON documents without any problems, but when I'm trying a .webm or .mp4 video, I keep getting only the JSON metadata (same you get if you don't add the "?alt=media" querystring to the Cloud Storage call. The strange thing is, I can easily proxy .webm videos from other sites. It's almost if Cloudflare Workers is rewriting the HTTP headers in the sub requests. Anyone know anything about this?
1 Reply
Just to elaborate, the URL for the Google Cloud Storage file is:
https://www.googleapis.com/storage/v1/b/{bucket-name}/o/{path-to-file.webm}?alt=media
With a "Bearer XXX" authentication token.
When trying from PostMan, everything works fine.
When trying to fetch another webm video (like this:
return fetch("https://dl6.webmfiles.org/big-buck-bunny_trailer.webm");
- it works fine.
But when I try the Google Storage link, the result is JSON:
Which is what you would expect if the "?alt=media" querystring wasn't added.
I can't wrap my head around this, unless Cloudflare is somehow removing the querystring. But when I just request a JSON document, I get the real content of the remote file, not the metadata. So I have no idea what's going on.
Turned out that only files with .json, .txt and without extension are allowed. No idea if this is caused by a special header sent by Cloudflare, or what's going on. But the fix was to store the file without an extension