Skip to content

Make this package use my Axios instance #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Zhythero opened this issue May 8, 2020 · 3 comments
Open

Make this package use my Axios instance #15

Zhythero opened this issue May 8, 2020 · 3 comments

Comments

@Zhythero
Copy link

Zhythero commented May 8, 2020

Hi,

So I have this nuxt module installed along with nuxt's axios module.
My axios instance is currently having a X-XSRF-TOKEN header configured inside it (because Laravel Sanctum) and I need this module to use the axios instance so that I can authenticate my SPA with Laravel's Broadcasting.

@ricardogobbosouza
Copy link
Member

Hi @Zhythero

I will make headers accept a function.
In the meantime you can create a plugin

// nuxt.config.js
export default {
  buildModules: [
    '@nuxtjs/laravel-echo'
  ],
  echo: {
    plugins: ['~/plugins/echo.js']
  }
}
// plugins/echo.js
export default function ({ $echo, app }) {
  $echo.options.auth.headers['X-XSRF-TOKEN'] = 'TOKEN'
  $echo.connect()
}

@ricardogobbosouza
Copy link
Member

Hi @Zhythero
Try this version: 2.0.0-alpha.1
Added support for Laravel Sanctum with auth-module v5
https://github.com/nuxt-community/laravel-echo-module/blob/main/src/runtime/echo.ts#L37

@ricardogobbosouza
Copy link
Member

#47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants