Skip to content

Commit

Permalink
add custom domain with images example (cloudflare#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauragift21 authored Aug 24, 2022
1 parent f1ade9b commit eee01cb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/custom-domain-for-images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
async fetch(request) {
// You can find this in the dashboard, it should look something like this: ZWd9g1K7eljCn_KDTu_MWA
const accountHash = '';

const { pathname } = new URL(request.url);

// A request to something like cdn.example.com/83eb7b2-5392-4565-b69e-aff66acddd00/public
// will fetch "https://imagedelivery.net/<accountHash>/83eb7b2-5392-4565-b69e-aff66acddd00/public"

return new Response(`https://imagedelivery.net/${accountHash}${pathname}`);
},
};

0 comments on commit eee01cb

Please sign in to comment.