1

For the sake of making my use-case more understandable, I'll classify services like Figma, WhatsApp, etc as SPAs. I've never received a page-expired error from those "SPAs".

So it is 2020, and we now also have Laravel 8: is it appropriate to use Sanctum to achieve such never-expiring SPA just by placing all routes in api.php, assuming that the SPA is in the same domain/subdomain with the Laravel app?

Btw, according to the Sanctum docs, this implies the use of API tokens for those API routes, but this kind of usage for first-party SPA is clearly not the intended use of Laravel Sanctum.

Damilola Olowookere
  • 2,253
  • 2
  • 23
  • 33

2 Answers2

1

Maybe not the best way to achieve that but if it works you'll get your job done and I don't see the problem of making that even if it was intended for another use

therealwalim
  • 252
  • 1
  • 4
  • 18
0

It seems Sanctum cannot handle this case, because if request is from the frontend, it applies session based auth checks.

I have however proposed a possible update that can make this possible. Hopefully, it will be considered for implementation.

In the meantime, a sane workaround that does not pose any serious security threat for my use-case is to increase the session timeout

Damilola Olowookere
  • 2,253
  • 2
  • 23
  • 33