Custom response with bearerAuth
I would like to return a custom response when verifyToken is false.
Is it possible?
Is it possible?
const authMiddleware = bearerAuth({
verifyToken: async (token, c) => {
const data = await c.env.AUTH.get(token);
if (!data) {
return false; // response: Plz provide valid apiKey
}
if (data.count > data.quota) {
return false; // response: Quota exceeded
}
return true;
},
});