Skip to content
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

v2.0.0-alpha.1 with laravel sanctum is broken #48

Open
yoelpc4 opened this issue Apr 4, 2021 · 14 comments
Open

v2.0.0-alpha.1 with laravel sanctum is broken #48

yoelpc4 opened this issue Apr 4, 2021 · 14 comments

Comments

@yoelpc4
Copy link

yoelpc4 commented Apr 4, 2021

Hi @ricardogobbosouza I have these package versions

dependencies:

  1. @nuxtjs/auth-next 5.0.0-1613647907.37b1156
  2. nuxt ^v2.15.4
  3. pusher-js ^7.0.3

devDependencies

  1. @nuxtjs/laravel-echo ^2.0.0-alpha.1

with the following nuxt config

buildModules: [
  ...
  '@nuxtjs/laravel-echo',
],

echo: {
    authEndpoint: '/laravel/broadcasting/auth',
    authModule: true,
    broadcaster: 'pusher',
    cluster: 'ap1',
    connectOnLogin: true,
    disconnectOnLogout: true,
    encrypted: true,
    forceTLS: true,
    key: process.env.PUSHER_APP_KEY,
},

modules: [
    ...
    '@nuxtjs/auth-next',
],

As you suggest to install v2.0.0-alpha.1 on recent issue #47 along with nuxt auth next laravel sanctum strategy, it resulted ReferenceError "location is not defined" on this line:

headers.referer = location.origin

@ricardogobbosouza
Copy link
Member

Hi @yoelpc4
Thanks for reporting
I will correct

@ricardogobbosouza
Copy link
Member

Hi @yoelpc4
Try ^2.0.0-alpha.2

@yoelpc4
Copy link
Author

yoelpc4 commented Apr 7, 2021

Hi @ricardogobbosouza

It seems that the @nuxtjs/laravel-echo plugin isn't calling connect method at all although I've logged in through nuxt auth.

nuxt.config.js

buildModules: [
  ...
  '@nuxtjs/laravel-echo',
],

echo: {
    authModule: true,
    broadcaster: 'pusher',
    cluster: 'ap1',
    connectOnLogin: true,
    disconnectOnLogout: true,
    encrypted: true,
    forceTLS: true,
    key: '...',
    optionsPath: './laravel-echo.options.js',
},

modules: [
    ...
    '@nuxtjs/auth-next',
],

with the following laravel-echo.options.js

export default ({ $axios }) => ({
  authorizer: (channel) => ({
    authorize: (socketId, authorizerCallback) =>
      $axios
        .post('/backend/api/broadcasting/auth', {
          channel_name: channel.name,
          socket_id: socketId,
        })
        .then(({ data }) => authorizerCallback(false, data))
        .catch((error) => authorizerCallback(true, error)),
  }),
  onAfterConnect() {
    console.log('laravel echo connected')
  },
})

Because the onAfterConnect hook is not invoked and I've checked out on pusher debug console there's no connection logs at all.

@radudiaconu0
Copy link
Contributor

radudiaconu0 commented Apr 7, 2021

I get 401 Unauthorized error

@ricardogobbosouza
Copy link
Member

Hi @yoelpc4
Sorry, had a problem with the options.

Try ^2.0.0-alpha.4

@radudiaconu0
Copy link
Contributor

radudiaconu0 commented Apr 7, 2021

@ricardogobbosouza now it doesnt connect to my websocket server(laravel-websockets)

@ricardogobbosouza
Copy link
Member

@radudiaconu0 Please provide a repository

@radudiaconu0
Copy link
Contributor

radudiaconu0 commented Apr 7, 2021

@ricardogobbosouza
Copy link
Member

Hi @radudiaconu0
I couldn't even register for your application, I configured the frontend and the backend

https://github.com/radudiaconu0/cheermeapp-frontend/
https://github.com/radudiaconu0/cheermeapp-backend/

Always with error CSRF token mismatch.

@radudiaconu0
Copy link
Contributor

@ricardogobbosouza set domains from cheermeapp.test to localhost. In laravel app and nuxtapp

@alitnk
Copy link

alitnk commented Apr 8, 2021

"@nuxtjs/laravel-echo": "^2.0.0-alpha.5",
"nuxt": "^2.14.12",
"@nuxtjs/auth-next": "5.0.0-1613647907.37b1156",
"pusher-js": "^7.0.3",

in nuxt.config.js:

echo: {
    ...
    broadcaster: 'pusher',
    authModule: true,
}

My connector is set to NullConnector when I set authModule to true, But when I set it back to false, it's a PusherConnector again.
Am I doing something wrong?

@Shar0w
Copy link

Shar0w commented May 17, 2021

Hello.
Does not work for me either

When I set authModule to true, I get this error:

TypeError: Cannot read property 'bind' of undefined
at Echo.watchAuthState (echo.js?38ae:55)
at Echo._callee$ (echo.js?38ae:13)
at tryCatch (runtime.js?96cf:63)
at Generator.invoke [as _invoke] (runtime.js?96cf:293)
at Generator.eval [as next] (runtime.js?96cf:118)
at asyncGeneratorStep (asyncToGenerator.js?1da1:3)
at _next (asyncToGenerator.js?1da1:25)

@djoks
Copy link

djoks commented Jun 17, 2021

Having the same issue. Looks like v2 is buggy.

@Shar0w
Copy link

Shar0w commented Jun 19, 2021

Having the same issue. Looks like v2 is buggy.

Yes. That's why I used v1

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

No branches or pull requests

6 participants