Skip to content
Visit Workers on GitHub
Set theme to dark (⇧+D)

Respond with another site

Respond to the Worker request with the response from another website ( in this example).

addEventListener('fetch', function(event) {  event.respondWith(handleRequest(event.request))})async function handleRequest(request) {  // Only GET requests work with this proxy.  if (request.method !== 'GET') return MethodNotAllowed(request)  return fetch(``)}function MethodNotAllowed(request) {  return new Response(`Method ${request.method} not allowed.`, {    status: 405,    headers: {      'Allow': 'GET'    }  })}


Open demo