Fetch Remote Resource

In this example, an Edge Function is used to fetch a remote resource and send it to the client.

Code

const RESOURCE_URL = 'https://data.playground.edgeone.ai/resource/image/png/edgeone-logo.png';

async function handleRequest() {
  const response = await fetch(RESOURCE_URL);
  return response;
}

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

Preview

Xnip2024-07-15_16-59-42.png

References