https://supertokens.com/ logo
Title
h

HHChift

03/10/2023, 11:00 AM
Hey, with React, we are using Axios for our API calls to our backend. We were using before the ST Axios interceptor but I see it's deprecated now. Based on your doc, I see that the tokens are automatically added to every fetch/xrh calls to our backend but this is not very customisable. We have a few axios calls where we don't have to have ST security on it & auto refresh calls, how can we disable ST for an axios instance ?
r

rp

03/10/2023, 12:09 PM
Hey @HHChift
You can override the addXhrInterceptor recipe function on the frontend’s session.init and just do nothing in the body. This will disable auto adding interceptors to axios
You can then continue to use the addAxiosInterceptor to the axios instances that you want
h

HHChift

03/10/2023, 12:15 PM
And we can use the addAxiosInterceptor even if its deprecated ?
r

rp

03/10/2023, 12:16 PM
Yes.
h

HHChift

03/10/2023, 1:06 PM
Can you point me out to the documentation of addXhrInterceptor ?
Which recipe and how to override ? it seems not part of your documentation
r

rp

03/10/2023, 2:50 PM
You want to use the override config in session.init on the frontend, and provide the
addXMLHttpRequestInterceptor
function to it from the recipe interface (https://supertokens.com/docs/auth-react/modules/recipe_session.html#RecipeInterface)