qruto / laravel-wave

Painless Laravel Broadcasting with SSE
MIT License
724 stars 30 forks source link

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

Closed victorcesae closed 8 months ago

victorcesae commented 1 year ago

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

ezequidias commented 1 year ago

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

victorcesae commented 1 year ago

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

slavarazum commented 1 year ago

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

slavarazum commented 8 months ago

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