Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mooseh's avatar

sanctum API requests?

So I have an application that I am attempting to move into laravel with inertiaJS and jetstream.

I have a status route that is in the api routes which can be found at /api/status

in which my application would xhr GET this every 10 seconds.

in sanctum i'm not sure how to get this working because when I hit /api/status with axios I get unauthenticated.

I know i can pass the status values in with inertia but how do i poll this often?

I assumed axios would be able to do this as long as i used window.axios.defaults.withCredentials = true;

but this does not seem to be the case.

0 likes
1 reply
mooseh's avatar
mooseh
OP
Best Answer
Level 5

Okay finally i figured it out, took a little digging around. so the steps i needed to take (because im working remotely was the issue)

I needed this line in the env to start as my server is remote and i am using a domain to access it. SANCTUM_STATEFUL_DOMAINS=".mydomain.com"

next we need to enable stateful it in the api which can be found in the laravel docs under installation here https://laravel.com/docs/8.x/sanctum

and lastly make sure the line I put in my original post is in the boostrap.js. window.axios.defaults.withCredentials = true;

1 like

Please or to participate in this conversation.