nuxt-community / axios-module

Secure and easy axios integration for Nuxt 2
https://axios.nuxtjs.org
MIT License
1.19k stars 245 forks source link

Axios interceptors not working when added to auth plugin option. #470

Closed alucardu closed 3 years ago

alucardu commented 3 years ago

I have simple plugin:

axios.js

export default ({ $axios }) => {
  $axios.interceptors.request.use((req) => {
    console.log('request: ', req)
    return req
  })

  $axios.interceptors.response.use((req) => {
    console.log('response: ', req)
    return req
  })
}

nuxt.config.js

  plugins: [
    { mode: 'client', src: '~/plugins/axios' }
  ],

When I run my Nuxt config like this and do a request the console.log is triggered.

But when I add the plugin to the nuxt auth plugin options:

  auth: {
    // omitted
    plugins: [
      { mode: 'client', src: '~/plugins/axios' }
    ]
  },

The console.log isn't triggered anymore.

atinux commented 3 years ago

@JoaoPedroAS51 do you mind quick checking this issue?

JoaoPedroAS51 commented 3 years ago

@Atinux Sure! We are checking at https://github.com/nuxt-community/auth-module/issues/1026

atinux commented 3 years ago

Closing here then.