D
D
devlocal2019-02-18 23:31:33
Vue.js
devlocal, 2019-02-18 23:31:33

Laravel + vue + asios how to correctly execute a redirect if the user is not authorized in ajax requests?

There is an application on laravel + vue + axios (requests to the server)
All requests are only for authorized users, except for authorization and registration.
How to correctly implement an automatic redirect to the authorization page if the session (authorized user) has expired (for example, the application was opened in the browser for a long time without actions) and the user requested some data from the server, which the application in the browser receives by request using axios ?
The option with session tracking in each axios request does not work because there are a lot of such places in the application. I think there should be some kind of mechanism that allows you to register actions for all application requests in one place.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2019-02-18
@devlocal

Interceptors.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question