How does middleware work in NextJS if you cannot export it

As I am trying to implement a system where users will not be able to access admin routes unless they are authenticated, to do this you need a middleware. But the problem is I am using nginx on my website, and you cannot use middleware on this, as it says:

error Middleware cannot be used with "output: export". See more info here: https://nextjs.org/docs/advanced-features/static-html

I am so confused on how this all works. How will you be able to use a middleware? Are there ways to not give users access to routes eg: [website]/admin/items/list unless they are authenticated?