title: Control cloudflare origin server using workers
body: <p>I'm trying to use a cloudflare worker to dynamically set the origin based on the requesting IP (so we can serve a testing version of the website internally)</p>
  
  <p>I have this</p>
  
  <pre><code>addEventListener('fetch', event =&gt; {
  event.respondWith(handleRequest(event.request))
  })
  
  async function handleRequest(request) {
  if (request.headers.get("cf-connecting-ip") == '185.X.X.X')
  {
  console.log('internal request change origin');
  }
  
  const response = await fetch(request)
  console.log('Got response', response)
  return response
  }
  </code></pre>
  
  <p>I'm not sure what to set. The request object doesn't seem to have any suitable parameters to change.</p>
  
  <p>Thanks</p>