Streaming under custom domain

#1

We are an educational company providing content to schools in Australia. In addition to website content which works great under CloudFlare we also deliver video.

The problem is the cloudflare streaming domain is blocked by a lot of school networks - for instance the majority of public schools. Is it possible to use a custom domain? Or can we deliver video through our domain in combination with a worker or proxy?

Looking for the best delivery solution possible - were almost there with this.

Thanks in advance for any help,

#2

Not possible out of the box, but try contacting sales https://www.cloudflare.com/products/cloudflare-stream/ (click contact) and perhaps they will be able to build a custom solution (I can’t say for certain; this is a big ask).

#3

Thanks @Judge - its a great product as stated, but getting behind government and education firewalls is proving to be a pain! Will try and connect with the stream team and see if they have something in the pipeline.

#4

Yes you will do that with cloudflare workers.

Go to your workers and try this;

function translateResponseLocation(headers) {
  const newHeaders = new Headers(headers);
 //Delete Cloudflare default access control allow origin header
  if (headers.has("Access-Control-Allow-Origin")) {
       newHeaders.delete("Access-Control-Allow-Origin")       
  }
  newHeaders.delete("access-control-expose-header") 
  newHeaders.delete("set-cookie")
 //Now add our domain access control allow origin header
  newHeaders.set("Access-Control-Allow-Origin","https://yourdomain.com")       
  return newHeaders;
}

async function handleRequest(request) {
  const parsedUrl = new URL(request.url)
  let path = parsedUrl.pathname.replace("/stream","")
  let search = parsedUrl.search
  var last = path + search

  let response = await fetch("https://videodelivery.net" + last)

  return new Response(
        response.body,
        {
            status: response.status,
            statusText: response.statusText,
            headers: translateResponseLocation(response.headers)
        }
    )
  
}

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

At last you have to enable for this worker https://yourdomain.com/stream/*

Fore example cloudflare manifest urls
MPEG-DASH: https://videodelivery.net/VIDEOID/manifest/video.mpd
HLS: https://videodelivery.net/VIDEOID/manifest/video.hls

You have to change that
MPEG-DASH: https://yourdomain.com/stream/VIDEOID/manifest/video.mpd
HLS: https://yourdomain.com/VIDEOID/manifest/video.hls

Now u can use cloudflare video sources your own domain and own video player with using workers.

Regards.

#5

Thanks olgarverim - Will try it and report back.