qruto / laravel-wave

Painless Laravel Broadcasting with SSE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Using Laravel Wave with the frontend in different url or port

victorcesae opened this issue · comments

What happened?

When using frontend in a url or port different of the backend, the connection is not stablished and i cannot configure custom url or port

How to reproduce the bug

Using frontend framework like NEXT.JS

Package Version

0.7.1

PHP Version

8.2.0

Laravel Version

9.0

How to Solve?

I created a repository to present the solution to the problem: https://github.com/victorcesae/feature-laravel-wave-client

Notes

No response

I already used laravel wave with front end applications like next.js!!
By default the configuration would be like this:

window.Echo = new Echo({
    broadcaster: WaveConnector,
    debug: true,
    endpoint: '/wave',
    authEndpoint: '/broadcasting/auth',
  })

if you want different host and ports from a front end application! use these settings below:

window.Echo = new Echo({
    broadcaster: WaveConnector,
    debug: true,
    endpoint: 'http://localhost:8080/wave', 
    authEndpoint: 'http://localhost:8080/broadcasting/auth',
  })

you can already add host and port! you can also add docker container host

I already used laravel wave with front end applications like next.js!! By default the configuration would be like this:

window.Echo = new Echo({
    broadcaster: WaveConnector,
    debug: true,
    endpoint: '/wave',
    authEndpoint: '/broadcasting/auth',
  })

if you want different host and ports from a front end application! use these settings below:

window.Echo = new Echo({
    broadcaster: WaveConnector,
    debug: true,
    endpoint: 'http://localhost:8080/wave', 
    authEndpoint: 'http://localhost:8080/broadcasting/auth',
  })

you can already add host and port! you can also add docker container host

I understand the concept but when you set a url as endpoint the property loose sense, but i will try this way

I tried here, and when I connect to laravel wave in the postman for example, other requests in route like, "/api/users", is not being completed, it remains pending, I have to restart the server for the requests return to normal

@victorcesae Do you have separate urls for client and server parts? /wave should works well if a main url is http://localhost:8080

If you still have the issue on the latest version, leave a comment here.