DEV Community

Brian Dillingham
Brian Dillingham

Posted on

Jetstream / Inertia redirect login with axios & intended

If you have to use axios and need to catch 401 errors (unauthorized) and redirect to login but want to redirect back: simply route an inertia request to the current url and it will handle routing to login and set intended in the session

.catch(errors => {
    if (errors.response && errors.response.status === 401) {
        this.$inertia.get(window.location)
    }
})
Enter fullscreen mode Exit fullscreen mode

Top comments (0)