DIYgod/RSSHub · error · ConfigNotFoundError

Google Fonts API key is required.

Error message

Google Fonts API key is required.

What it means

The Google Fonts route calls the webfonts v1 API, which requires an API key. The handler reads `config.google.fontsApiKey` and throws ConfigNotFoundError if it is falsy. This route is explicitly self-host-only.

Source

Thrown at lib/routes/google/fonts.tsx:53

    name: 'Google Fonts',
    maintainers: ['Fatpandac'],
    handler,
    description: `| Newest | Trending | Most popular |  Name | Number of styles |
| :----: | :------: | :----------: | :---: | :--------------: |
|  date  | trending |  popularity  | alpha |       style      |

::: warning
This route requires API key, therefore it's only available when self-hosting, refer to the [Deploy Guide](https://docs.rsshub.app/deploy/config#route-specific-configurations) for route-specific configurations.
:::`,
};

async function handler(ctx) {
    const sort = ctx.req.param('sort') ?? 'date';
    const limit = ctx.req.param('limit') ?? 25;

    const API_KEY = config.google.fontsApiKey;
    if (!API_KEY) {
        throw new ConfigNotFoundError('Google Fonts API key is required.');
    }

    const googleFontsAPI = `https://www.googleapis.com/webfonts/v1/webfonts?sort=${sort}&key=${API_KEY}`;

    const response = await got.get(googleFontsAPI);
    const data = response.data.items.slice(0, limit);

    return {
        title: `Google Fonts - ${titleMap[sort]}`,
        link: 'https://fonts.google.com',
        item:
            data &&
            data.map((item) => ({
                title: item.family,
                description: renderDescription(item),
                link: `https://fonts.google.com/specimen/${item.family.replaceAll(/\s/g, '+')}`,
                pubDate: parseDate(item.lastModified, 'YYYY-MM-DD'),
            })),

View on GitHub (pinned to bed535e087)

Solutions

  1. Obtain a Google Fonts API key from Google Cloud Console and set config.google.fontsApiKey (env: GOOGLE_FONTS_API_KEY), then restart.
  2. If you cannot supply a key, this route is unavailable — it is documented as self-host-only.
  3. Confirm the env var name against the route-specific config section of the deploy guide.
Defensive patterns

Strategy: validation

Validate before calling

import { config } from '@/config';
function googleFontsConfigured(): boolean {
  return Boolean(config.google?.fontsApiKey);
}

Type guard

function googleFontsConfigured(): boolean {
  return Boolean(config.google?.fontsApiKey);
}

Prevention

When it happens

Trigger: Self-hosting without setting the Google Fonts API key env var; the key was cleared from config.

Common situations: Fresh deploy missing GOOGLE_FONTS_API_KEY (or the equivalent config path); using the public rsshub.app instance, which does not expose this route.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/8321fbb6bb87c438. Report an issue: GitHub.