Skip to content

[BUG] terminal页面构造WebSocket URL错误 #330

@momo8711

Description

@momo8711

描述BUG/Describe the Bug

terminal页面构造WebSocket URL错误

复现步骤/To Reproduce

1、开开心心地通过docker-compose部署Komari
2、兴致勃勃地添加服务器,并配置好agent
3、点击终端按钮,自动跳转到URL https://jxxxxx83.status.xxxxxxan.com/terminal?uuid=c14a5030-a105-xxxx-xxxx-xxxxxxxxx4a7
4、痛苦地发现该页面报错(如图)

截图/Screenshots

Image Image

环境/Environment

  • OS: Windows 11
  • 浏览器/Browser: Chrome 122
  • 版本/Version: 1.1.1b (34654c0)

问题分析/Problem Analysis

页面构造的WebSocket URL是错误的
构造的URL:./api/admin/client/c14a5030-a105-xxxx-xxxx-xxxxxxxxx4a7/terminal
存在问题:不能使用以 ./ 开头的相对路径,且需要明确指定协议(ws:// 或 wss://)

解决方案/Solution

修正构造WebSocket URL的过程,根据http协议判断ws/wss,并根据host构造完整URL
例如:wss://jxxxxx83.status.xxxxxxan.com/api/admin/client/c14a5030-a105-xxxx-xxxx-xxxxxxxxx4a7/terminal

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions