Search code examples
amazon-cloudfrontgoogle-fonts

Is it possible to use AWS Cloudfront to proxy Google Fonts?


I have created an AWS Cloudfront distribution in an attempt to proxy requests to fonts.googleapis.com through Cloudfront. So for example, I'd like to use something list this:

https://xxxxxx.cloudfront.net/css2?family=Noto+Sans+HK:wght@400;500;700;900&display=swap

To fetch the actual content from the origin at:

https://fonts.googleapis.com/css2?family=Noto+Sans+HK:wght@400;500;700;900&display=swap

I have configured Cloudfront with an origin of "fonts.googleapis.com" and set it so that it passes through all URL parameters, but still the origin responds with:

404. That’s an error.
The requested URL /css2 was not found on this server.

Does anyone know what could be causing this? Afaik, the way I've configured Cloudfront should act like a transparent pass-through.

I can't share all of the Cloudfront config settings here (there are too many), but perhaps someone can point me in the right direction?

Or is this impossible?


Solution

  • This in fact did work fine. I had just setup the CloudFront distribution incorrectly.