to SIP URIs? Something like, / * GEO SIP redirector * * - Redirect users based on their location to different SIP URIs /
export default { async fetch(request) { /** * A map of the SIP URIs to redirect to based on country * @param {Object} countryMap */ const countryMap = { US: "houston2.voip.ms", EU: "london1.voip.ms", CA: "houston2.voip.ms" };
// Use the cf object to obtain the country of the request const country = request.cf.country;
if (country != null && country in countryMap) { const sipUri = countryMap[country]; // Remove this logging statement from your final output. console.log(
Based on ${country}-based request, your user would go to ${sipUri}.
Based on ${country}-based request, your user would go to ${sipUri}.
); return new Response(null, { status: 302, headers: { "Location":
sip:${sipUri}
sip:${sipUri}
} }); } else { // Default redirection if country is not found return new Response(null, { status: 302, headers: { "Location": "sip:aaa.voip.ms" } }); } }, };