I now have a requirement to use the api so that I can make a call to it using ajax to pull in some data from some models.
Using the same method as above, despite the user being signed in, they're redirected to the login page (if going to the api route directly in the browser).
If you have a routes.php file it must be an old laravel version? Now it's web.php. Anyways. Api is stateless by default so you cannot be signed in with sessions. Either use routes.php or use something like sanctum for to enable sessions for those routes. Personally I would go for the first (or make a new route file for ajax)