Geolocation Worker headers

We have a Cloudflare Enterprise plan and want to pass in the regionCode (state abbreviation) into the header response back to the client. The Cloudflare request is req.cf.regionCode but for whatever reason I constantly get an error when I try to assign it to a variable so there is something wrong with the syntax.

Ultimately the header output should be:

state: CA (would show the state abbreviation from the client’s IP lookup, in this case it would be California)

addEventListener("fetch", event => {
  event.respondWith(fetchAndReplace(event.request))
})

async function fetchAndReplace(request) {
  
  const res = await fetch(request)
  let modifiedHeaders = new Headers() 
  let state = (req.cf.regionCode)
  

  modifiedHeaders.set('Content-Type', 'text/html')
  modifiedHeaders.append('Pragma', 'no-cache')
  modifiedHeaders.append("state", `${state}`) 


  //Return maint page if you're not calling from a trusted UA
  if (request.headers.get("User-Agent") !== "Preprod") 
  {
    // Return modified response.
    return new Response(maintPage, {
      status: 503,
      headers: modifiedHeaders
    })
  }
  else //Allow users from trusted into site
  {
    //Fire all other requests directly to our WebServers
    return fetch(request)
  }
}

let maintPage = `
This is a test
`;

I think you mean to write

let state = (request.cf.regionCode)