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();
});
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();
});