Problem
Creating Axios instance from @nuxtjs/axios and adding supertoken Interceptor is breaking, causing token refreshing to work incorrectly. Interceptors are getting added after first request.
Code
/plugins/axios.js
import SuperTokens from 'supertokens-website';
export default function ({ $axios, $config }, inject) {
// Create a custom axios instance
const axiosInstance = $axios.create({
baseURL: $config.root,
});
// Add SuperTokens interceptors
SuperTokens.addAxiosInterceptors(axiosInstance);
// Inject to context as $axios
inject('axios', axiosInstance);
}
nuxt.config.js
plugins: ['~/plugins/axios']
Solution for users
Using Axios from Axios package (not from @nuxtjs/axios) and injecting it into Nuxt.js context fixes the issue.
Using Nuxt.js - 2.15.8 @nuxtjs/axios - 5.13.6 SuperTokens-website - 10.0.5 SuperTokens-node - 8.2.0
Problem Creating Axios instance from @nuxtjs/axios and adding supertoken Interceptor is breaking, causing token refreshing to work incorrectly. Interceptors are getting added after first request.
Code /plugins/axios.js
nuxt.config.js
Solution for users Using Axios from Axios package (not from
@nuxtjs/axios
) and injecting it into Nuxt.js context fixes the issue.