T
TanStack9mo ago
stormy-gold

Is it possible to add middleware to API routes?

Hi all, is it possible to add middleware to API routes? I need to implement authentication but couldn’t find relevant documentation. Any guidance or resources would be appreciated! Thanks in advance!
7 Replies
modern-teal
modern-teal9mo ago
Sure. Do u wanna add Nuddkeware to globally or specific routes?
stormy-gold
stormy-goldOP9mo ago
examples on how to do both would be great, thanks.
rival-black
rival-black9mo ago
which kind of middleware do you want to add? server function Middleware? nitro Middleware?
stormy-gold
stormy-goldOP9mo ago
nitro middleware (I suppose). I want to add middleware to API routes.
stormy-gold
stormy-gold8mo ago
Ah middleware for API routes and not for server functions. not sure if this is helpful
stormy-gold
stormy-gold8mo ago
stormy-gold
stormy-gold8mo ago
all i know is that nitro is using h3 under the hood.

Did you find this page helpful?