Skip to content

Instantly share code, notes, and snippets.

@jasonbyrne
Created April 27, 2020 13:56
Show Gist options
  • Save jasonbyrne/d8743964120160b5509e95751cb16bf3 to your computer and use it in GitHub Desktop.
Save jasonbyrne/d8743964120160b5509e95751cb16bf3 to your computer and use it in GitHub Desktop.
Figure out different asset domains based on which CDN provider
const hosts = {
cloudFlare: "https://flosports-video.s3.amazon.com",
stackPath: "https://cdn.stackpath.flosports.tv",
};
function isStackPath(request: Request): boolean {
const url = new URL(request.url);
return !!url.hostname.match(/stackpath/);
}
export function getAssetHost(request: FloRequest) {
return hosts[isStackPath ? 'stackPath' : 'cloudFlare'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment