dystcz / nuxt-sanctum-auth

Nuxt 3 + laravel sanctum authentication
134 stars 25 forks source link

Intercept global 401 (Unauthorized) #25

Open cvalues opened 1 year ago

cvalues commented 1 year ago

Hi,

how to intercept all 401 global, to redirect them to the login page? Is it possible to capture all 401s in a plugin and direct them to the login page? And if so, how ;) ?

thx alot!

kreejzak commented 1 year ago

Hi @cvalues, as of right now this is unfortunately not possible. All guarded pages must have auth middleware. Tho, you should be able to use nuxt nested pages.

I'm in the middle of a major rewrite that will introduce new features with global middleware among them. Stay tuned, unfortunately no firm timeframe, but soon (tm).

cvalues commented 1 year ago

Hi @kreejzak,

thanks for your repley and thanks for your good work. I stay tuned..

The problem does not exist with the page reload, everything works there. But if you are on the same page and the session has expired, the api throws errors and you cannot react to them.

KR