Edge runtime preferredRegions
Unanswered
Kasper posted this in #help-forum
KasperOP
Hi,
I'm trying to make an edge runtime function that reads the region it is executing in, using the x-vercel-id header. While doing this, I found an unexpected behaviour. I set my preferred regions to ['fra1', 'cle1']. Then I used a VPN in San Fransisco, and the header read sfo1::fra1. This indicated that the closest region is sfo1, which is not in my preferred regions array, so it just selected the first one in the array instead. I thought that the config would select the closest region in the array, not the first one if it's not a direct hit. Am I doing something wrong, or is this how it actually works?
I'm trying to make an edge runtime function that reads the region it is executing in, using the x-vercel-id header. While doing this, I found an unexpected behaviour. I set my preferred regions to ['fra1', 'cle1']. Then I used a VPN in San Fransisco, and the header read sfo1::fra1. This indicated that the closest region is sfo1, which is not in my preferred regions array, so it just selected the first one in the array instead. I thought that the config would select the closest region in the array, not the first one if it's not a direct hit. Am I doing something wrong, or is this how it actually works?
6 Replies
how abt swapping the list ['cle1', 'fra1'], then access via Germany? would it use cle1?
if so, it is the priority list, not a set of allowed regions.
it's a Vercel specific matter, so you might want to ask the Vercel GitHub community instead.
btw if you had an upstream DB/API in SF, the edge would be better in SF instead of EU. Indeed, Cloudflare edge, which Vercel uses under the hood, has a mechanism that automatically choose edge servers based on traffics rather than distance.
KasperOP
I have the main DB in Frankfurt and a read-only replica in Cleveland. If your closest edge server is not in the list, it uses the first one in the list, not the closest one to you in the list.
you can double check with Vercel community