Validate Session on Next.js Frontend with Express Backend

Hello everyone! I currently have set up betterAuth in my Express.js server backend storing users anad sessions in a Sqlite db. I created APIs in my Express server that call betterAuth functions like "auth.api.sign-up/email".

In my Next.js frontend I want to be able to restrict pages in my app using the session token returned from my API. I am confused on how to do this though since my betterAuth app lives on my backend in a different repo. Would I need to create a new express api called "/verify-session" and just call this everytime in my middleware.ts, to verify the user before opening any page?
Was this page helpful?