Support Forums

Is there a build variable based on Netlify's global server location?

I’m embedding video on my site using Amazon S3 and would like to link to the S3 server closest to the user.

For example, if the site is being served from Netlify’s San Francisco facility then the code would reference AWS US-West. If it’s being served from Netlify’s Singapore facility the code would link to the AWS Hong Kong server.

Is there a build variable that makes this possible?

hi there,

there is no variable like the one you are describing, even though that is how Netlify’s CDN works under the hood - we have a network of globally sync’d servers that serve the content to the requester from the geographically closest node.

Does this answer your question? What would your end goal be for having a variable?

Does this answer your question?

Yep, thanks!

What would your end goal be for having a variable?

I don’t use Netlify to host my large files, I use Amazon S3. I would like to be able to serve large files to my visitors from the nearest available S3 bucket. As of now, all video content is served from the US.

Here’s a (very rough) pseudocode sample of how I would use this hypothetical information at build.

  s3bucket = "north-america.amazonaws.com"

  s3bucket = "asia-pacific.amazonaws.com"

And then in the actual html:

  <source src="{{ s3bucket }}my-video-name.mp4">

I really didnt think through where the variables would go or how they would be accessed. I’m just trying to get the rough idea across. I hope that helped.

Hi, perhaps you could use something like this to detect the location and then serve a specific URL based on that. Would that work for you?

Just following up on this for anyone interested.

Apparently Amazon offers a cloudfront service that will not only deliver from the nearest available data center, they also transcode your videos and deliver video quality based on the user’s connection speed. This will probably be the path I go down to solve this.

Thanks to everyone who replied. I appreciate the support on here while I get comfy with all things Netlify.

1 Like