Lesourdingo
Lesourdingo
HHono
Created by Lesourdingo on 7/10/2024 in #help
Custom response with bearerAuth
I would like to return a custom response when verifyToken is false.
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;
},
});
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;
},
});
Is it possible?
2 replies