Found the answer on another forum. I was not using the auth middleware. To fix it, in my routes file all I had to do was add:
import { middleware } from '#start/kernel' router.get('/', [HomeController, 'index']).use(middleware.auth())