Created
April 27, 2020 13:56
-
-
Save jasonbyrne/d8743964120160b5509e95751cb16bf3 to your computer and use it in GitHub Desktop.
Figure out different asset domains based on which CDN provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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