nblshi
How can I redirect from server api?
I’ve set up Axios in the server/api folder, and my APIs are working well for fetch, update, delete, etc.
However, I’m facing an issue with token expiration. When the token expires, API will returns an error, and I want to redirect the user to the home page so they can log in again.
I’ve used Axios interceptors to detect the error and log it to the console, but I’m stuck on the redirect part. I can’t use useRoute, redirect, or navigateTo due to the error "vue app aliases are not allowed in server runtime."
Is there a workaround for handling redirects in this scenario?
1 replies