Sending Proxied Request in Worker - Cors Error

Hi, I’m new to working with Cloudflare Workers so there might be something obvious that I’m missing here. Within my worker, I’m needing to send a request to a URL through a proxy that requires user authentication. My code works fine in a normal Node project, but I’m receiving a Cors error when trying to run this in my worker. Here’s the code below:

const http = require('http')

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

const corsHeaders = {
  'Access-Control-Allow-Headers': '*',
  'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  'Access-Control-Allow-Origin': '*',
}


async function handleRequest(request) {
  if (request.method === 'OPTIONS') {
    return new Response('OK', {
      headers: corsHeaders
    })
  }

  if (request.method === 'POST') {
    const options = {
          host: 'PROXY_SERVER_IP',
          port: 'PROXY_SERVER_PORT',
          path: url,
          method: 'GET',
          headers: {
              'Proxy-Authorization': 'Basic ' + Buffer.from('username' + ':' + 'password').toString('base64'),
          }
      }

      let json;

      http.get(options, function(res) {
        res.on('data', function (data) {
            const number = parseInt(data)
            json = JSON.stringify({
                data: number
            })
        })
      })

      return new Response(json, {
        headers: {
          "content-type": "application/json",
          ...corsHeaders
        }
      }
    )
  }
}

These are the two errors I get: “Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8787/. (Reason: CORS request did not succeed).” and “Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8787/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).”

I’m following the tutorial for setting up Cors that Cloudflare provides, and I’m lost as to why this error is occurring. Everything runs fine if I remove the http.get request, but as soon as I add it back in I start getting this Cors error.

Does anyone know if I could change anything to get this working correctly?