A Cloudflare Worker that acts as a privacy-focused proxy for Google Fonts, allowing you to serve Google Fonts from your own domain without exposing user data to Google's servers.
- No IP tracking: User requests never reach Google's servers directly
- No referrer leakage: Your website visitors browsing data stays private
- Proxies Google Fonts CSS API (
fonts.googleapis.com/css2) - Proxies Google Fonts static files (
fonts.gstatic.com) - Automatic URL rewriting in CSS files
- Removes tracking headers and privacy-invasive headers
- Aggressive caching for optimal performance
- Health check endpoint
- Cloudflare account (free tier works)
- Custom domain or Cloudflare Workers subdomain
- Basic knowledge of Cloudflare Workers
- Log in to your Cloudflare Dashboard
- Go to Workers & Pages → Create application → Create Worker
- Replace the default code with the contents of
worker.js - Click Save and Deploy
- Optionally, set up a custom domain in the Triggers tab
-
Install Wrangler CLI:
npm install -g wrangler
-
Clone this repository:
git clone https://github.com/1Developpeur/FontGuard cd FontGuard -
Login to Cloudflare:
wrangler login
-
Deploy the worker:
wrangler deploy
Replace your Google Fonts URLs, only domain changes:
Before:
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">After:
<link href="https://your-worker-domain.workers.dev/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">Check if your worker is running:
curl https://your-worker-domain.workers.dev/healthYou can customize the worker behavior by modifying the code:
- Cache TTL: Adjust
cacheTtlvalues for different caching strategies - CORS: Modify
access-control-allow-originheader as needed - Headers: Add or remove headers from the
headersToRemovearray
Create a wrangler.toml file for advanced configuration:
name = "google-fonts-proxy"
main = "worker.js"
compatibility_date = "2024-01-01"
[env.production]
route = "fonts.yourdomain.com/*"| Endpoint | Description | Example |
|---|---|---|
/css2 |
Google Fonts CSS API | /css2?family=Inter:wght@400;500 |
/gstatic |
Font files (woff2, woff, ttf) | /gstatic/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7.woff2 |
/health |
Health check | Returns service status |
/ |
Service info | Returns basic service information |
IMPORTANT: This software is provided "as is" without warranty of any kind. Users are responsible for:
- Ensuring compliance with Google Fonts' Terms of Service
- Verifying compatibility with local privacy laws (GDPR, CCPA, etc.)
- Understanding that font files are still served from Google's infrastructure
- Monitoring usage to stay within Cloudflare Workers limits
The authors and contributors of this project:
- Make no warranties about the software's functionality or reliability
- Are not responsible for any damages or legal issues arising from its use
- Do not guarantee compliance with any specific privacy regulations
- Recommend consulting with legal counsel for compliance requirements
Use at your own risk and responsibility.
- 100,000 requests per day
- 10ms CPU time per request
- 128MB memory per request
No license provided. Use at your own risk and responsibility.
Fonts not loading:
- Check browser console for CORS errors
- Verify worker domain is accessible
- Ensure CSS URLs are correctly rewritten
Performance issues:
- Monitor Cloudflare Workers analytics
- Check cache hit rates
- Consider upgrading to Workers Paid plan for higher limits
GDPR compliance:
- This proxy doesn't guarantee compliance with GDPR
- Consult legal counsel for your specific requirements
- Consider adding privacy policy updates
Made with ❤️ for privacy-conscious developers