File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
app/channels/llama_bot_rails Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -209,9 +209,20 @@ def setup_external_websocket(connection_id)
209
209
end
210
210
211
211
uri = URI ( websocket_url )
212
-
213
- uri . scheme = 'wss'
214
- uri . scheme = 'ws' if Rails . env . development?
212
+
213
+ # Normalize the WebSocket URI scheme so it is always either ws:// or wss://.
214
+ # We want to gracefully handle users passing in http/https URLs or omitting a scheme entirely.
215
+ case uri . scheme &.downcase
216
+ when 'wss' , 'ws'
217
+ # already valid, do nothing
218
+ when 'https'
219
+ uri . scheme = 'wss'
220
+ when 'http'
221
+ uri . scheme = 'ws'
222
+ else
223
+ # If a scheme is missing or unrecognized, fall back to sensible defaults
224
+ uri . scheme = Rails . env . development? ? 'ws' : 'wss'
225
+ end
215
226
216
227
endpoint = Async ::HTTP ::Endpoint . new (
217
228
uri ,
You can’t perform that action at this time.
0 commit comments