Workers redirect for specific countries all the rest stay on the same site

Can I redirect visitors from the below countries to domain2?

China/Hongkong/Taiwan.

I have created a worker on domain1.

All rest countries should stay on the domain1.

I need your help with the script below.

Redirect a response based on the country code in the header of a visitor.

Redirect a response based on the country code in the header of a visitor.

/**

  • Returns a redirect determined by the country code
  • @param {Request} request
    */
    async function redirect(request) {
    // The cf-ipcountry header is not supported in the preview
    const country = request.headers.get(“cf-ipcountry”)

if (country != null && country in countryMap) {
const url = countryMap[country]
return Response.redirect(url)
}
else {
return await fetch(request)
}
}
/**

async function handleRequest(request) {
return redirect(request)
}

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