API Key Validation in Next.js middleware
I would like to protect my Next.js app's API endpoints using the API plugin. In my middleware, I keep getting, that my API keys are invalid when I get them from the request headers and validate them using the
auth.api.validateApiKey
function. Most of my configurations for the plugin are left as defaults. Kindly advise me on how I could get past this or what other approach I should consider. Thank you.1 Reply
I advise against using database queries in middleware. Do this in the route itself