nextjs 13 protected api routes

What is the best way to protect api in the new nextjs release, something like an internal middleware?
Was this page helpful?