Blocking specific routes based on user session

Hey, I was wondering what's the best approach to get user session and based on it prevent specific routes in website?

I though of doing that through middleware, however inside middlare I can't get session using this method:
const session = await auth.api.getSession({
    headers: await headers() // you need to pass the headers object.
})


As I it is not allowed to use Node’s dgram module in Edge runtime

What would be correct approach for this task?
Was this page helpful?