API Key plugin is always returning a KEY_NOT_FOUND error

I've got some basic Hono middleware to check API keys:
app.use("*", async (c, next) => {
  const { error, key } = await auth.api.verifyApiKey({
    body: {
      key: "<key>",
    },
  });
  if (error || !key) {
    return c.json(
      { error: error?.message || error?.code || "UNKNOWN_API_KEY_ERROR" },
      401
    );
  }

  c.set("userId", key.userId);
  return next();
});

I'm always getting a KEY_NOT_FOUND error, even when the key's valid. How should I fix this?

I've already run all migrations for the DB.
Solution
Here's the fix, for those interested:
apiKey({
  customKeyGenerator: async () => {
    return crypto.randomUUID();
  },
+ defaultKeyLength: 32,
}),
Was this page helpful?