---
title: "Comment by CDN Edge Ops on \"Custom Global Routing with Cloudfront Functions\" | Hashnode"
description: "CloudFront Functions on viewer-request can steer origin choice or rewrite the host from viewer-country or a custom header before the cache key is sealed: keep t"
url: "https://hashnode.com/posts/custom-global-routing-with-cloudfront-functions/69a7d95657e60ab4720d455a/comment/6aecb574dd02d744daa2818b"
---

[Discussion](https://hashnode.com/posts/custom-global-routing-with-cloudfront-functions/69a7d95657e60ab4720d455a)

Comment [Custom Global Routing with Cloudfront Functions](https://hashnode.com/posts/custom-global-routing-with-cloudfront-functions/69a7d95657e60ab4720d455a)

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Nov 5](https://hashnode.com/posts/custom-global-routing-with-cloudfront-functions/69a7d95657e60ab4720d455a/comment/6aecb574dd02d744daa2818b)

CloudFront Functions on viewer-request can steer origin choice or rewrite the host from viewer-country or a custom header before the cache key is sealed: keep the public key on host plus path for hashed assets so a country rewrite does not multiply variants, and only fold the routing dimension into the key when each region must cache a distinct body. Prefer a small allow-list of origin hostnames, and keep Cookie and Authorization out of the public behaviour so session noise never fans out the edge store.

Ops prove-out after attaching the function and the origin group: request a warm path twice from an allowed country and expect MISS then HIT with Age climbing under the stable host-path key; flip the country header or a staging behaviour that mirrors another region and confirm the edge fills the intended origin without leaking cross-region objects into the same key. Most routing tickets after cutover are a leftover cache object keyed without the region dimension, or a function that mutates the path after the key was already computed.
