laravel-websockets icon indicating copy to clipboard operation
laravel-websockets copied to clipboard

add possibility to set base url for websocket-server

Open N3XT0R opened this issue 3 years ago • 4 comments

Hey Guys, could you add a possibility to set the base url on the websocket-server? Actually its not possible to configure a websocket server behind a sub-url like (https://beyondco.de/docs/laravel-websockets/basic-usage/ssl#same-location-for-websockets-and-web-contents): location /ws { ... }

By configuring a websocket server at http://example.com/ws the route configuration does not match anymore in:

BeyondCode\LaravelWebSockets\Server\Router::echo(), so the websocket-server will permanently return 404 http status codes.

N3XT0R avatar Apr 07 '21 14:04 N3XT0R

I agree. Btw any ideas how to solve this now apart from proxy-server?

drmax24 avatar Apr 22 '21 14:04 drmax24

Using v2.0 beta 36

We can add WebSocketsRouter::addCustomRoute('GET', '/ws', \BeyondCode\LaravelWebSockets\Server\WebSocketHandler::class);

and set

    PUSHER_APP_PATH: 'ws'
    LARAVEL_WEBSOCKETS_PORT: '80'

(my env is yaml for helm k8s)

though it still does not work

I.e.: Me and N3XT0R want http://example.com/ws to be a websocket endpoint. Same domain as our websites. Same port as our websites but certain route.

drmax24 avatar Apr 23 '21 08:04 drmax24

@drmax24 You saved my day.

mrfarhadir avatar Aug 17 '21 13:08 mrfarhadir

But how to get echo/pusher to use the path prefix as well? I couldn't find an option to set the path for the client

captnCC avatar Oct 07 '21 15:10 captnCC