add missing cors bypass for RustDesk public web client

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2025-05-14 13:48:35 +08:00
parent de9255699c
commit d50eaa8653
3 changed files with 65 additions and 0 deletions
@@ -441,6 +441,28 @@ server {
如果您之前为 Web 客户端部署过,并想在所有平台上使用,您需要添加 `proxy_read_timeout`
{{% /notice %}}
#### 9. 如果您使用 RustDesk 公共 Web 客户端 `https://rustdesk.com/web`,需要绕过 CORS 限制
您需要在 `/etc/nginx/.../rustdesk.conf``location /` 部分添加以下内容,以绕过浏览器的 CORS 限制。如果您使用自己的 Web 客户端,可以跳过此步骤。
```
if ($http_origin ~* (https?://(www\.)?rustdesk\.com)) {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Content-Length' 0;
add_header 'Content-Type' 'text/plain charset=UTF-8';
return 204;
}
```
### 为什么我的日志/设备名称为空?
确保在被控制的设备上正确设置了 APIhttps://github.com/rustdesk/rustdesk-server-pro/issues/21#issuecomment-1637935750。