I am working on a little app where I am using NuxtJS with the laravel echo package for the frontend and Laravel8 with the LaravelWebsockets package for the backend. I am trying to make it work with private channels and passport in Laravel.
I've noticed something really strange that I can't really change or I don't know how to do that.
It looks like Laravel Echo package is making the request with FORM data instead of JSON body which I need and I have no clue if and how I could change it.
When I am trying to subscribe to a private channel(pusher as a broadcaster) echo makes a request to brodcasting/auth endpoint which is fine. However, the data in that request is sent as form data and not as JSON body.
I've made a little plugin in nuxtjs to add headers and stuff so I tried it like this:
My headers are added (although it seems like it is hardcoded in echo package to add application/x-www-form-urlencoded header).
As a result in my Laravel I am getting 403 error and when I traced the code back to where it breaks the data from request is missing. It is because Laravel at this points expects JSON body and it is not there.
My question is - can I somehow make Echo to send the application/json body? Maybe I am misunderstanding the whole thing?
Is there some other way to make this package for Nuxt to work nicely with passport?
Hey,
I am working on a little app where I am using NuxtJS with the laravel echo package for the frontend and Laravel8 with the LaravelWebsockets package for the backend. I am trying to make it work with private channels and passport in Laravel.
I've noticed something really strange that I can't really change or I don't know how to do that.
It looks like Laravel Echo package is making the request with FORM data instead of JSON body which I need and I have no clue if and how I could change it.
When I am trying to subscribe to a private channel(pusher as a broadcaster) echo makes a request to
brodcasting/auth
endpoint which is fine. However, the data in that request is sent as form data and not as JSON body.I've made a little plugin in nuxtjs to add headers and stuff so I tried it like this:
My headers are added (although it seems like it is hardcoded in echo package to add
application/x-www-form-urlencoded
header).As a result in my Laravel I am getting 403 error and when I traced the code back to where it breaks the data from request is missing. It is because Laravel at this points expects JSON body and it is not there.
My question is - can I somehow make Echo to send the
application/json
body? Maybe I am misunderstanding the whole thing?Is there some other way to make this package for Nuxt to work nicely with passport?