DEV Community

Brian Dillingham
Brian Dillingham

Posted on

2 1

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)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post