Skip to content

fix: add HTTPS support for microphone access on remote servers#11

Merged
ailuckly merged 1 commit into
developfrom
feat/realtime-voice-stt-p0-p1
Apr 11, 2026
Merged

fix: add HTTPS support for microphone access on remote servers#11
ailuckly merged 1 commit into
developfrom
feat/realtime-voice-stt-p0-p1

Conversation

@ailuckly
Copy link
Copy Markdown
Owner

  • Add getUserMedia availability check with clear error message
  • Add Nginx self-signed cert setup script (scripts/setup-https.sh) for enabling HTTPS on IP-only servers where mediaDevices is undefined

📌 变更内容

  • 如:新增用户登录 API
  • 如:修复登录失败时错误提示

✅ 测试验证

  • 本地运行通过
  • 自测通过
  • CI 流水线通过

PR 提交规范提醒:

  • 确保提交主题信息符合约定式提交规范 (feat/fix/docs/style/refactor/test/chore)
  • 确保代码已经通过本地测试
  • 确保没有提交敏感信息(密码、密钥等)

- Add getUserMedia availability check with clear error message
- Add Nginx self-signed cert setup script (scripts/setup-https.sh)
  for enabling HTTPS on IP-only servers where mediaDevices is undefined
Copilot AI review requested due to automatic review settings April 11, 2026 05:38
@ailuckly ailuckly merged commit 0380f39 into develop Apr 11, 2026
2 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves microphone/voice feature reliability when the app is accessed from remote (non-localhost) servers by adding an explicit getUserMedia availability guard in the web client and providing a helper script to enable HTTPS via Nginx with a self-signed certificate.

Changes:

  • Add a preflight check for navigator.mediaDevices.getUserMedia with a clear error message before starting recording.
  • Add scripts/setup-https.sh to generate a self-signed cert and write an Nginx HTTPS reverse-proxy config for IP-based access.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
vocata-web/src/utils/aiChat.ts Adds runtime guard to fail fast with a clear message when getUserMedia is unavailable (typically non-HTTPS contexts).
scripts/setup-https.sh Adds an automation script to generate certs and configure Nginx for HTTPS access to enable microphone permissions remotely.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/setup-https.sh
Comment on lines +7 to +34
SERVER_IP="86.53.161.33"
SSL_DIR="/etc/nginx/ssl"
NGINX_CONF="/etc/nginx/sites-available/vocata-https"

echo "=== 1. 生成自签 SSL 证书 ==="
mkdir -p "$SSL_DIR"

# 生成含 IP SAN 的证书(现代浏览器要求 SAN,不认纯 CN)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout "$SSL_DIR/vocata.key" \
-out "$SSL_DIR/vocata.crt" \
-subj "/C=CN/ST=Beijing/O=VocaTa/CN=$SERVER_IP" \
-addext "subjectAltName=IP:$SERVER_IP"

echo "证书已生成: $SSL_DIR/vocata.crt"

echo ""
echo "=== 2. 写入 Nginx 配置 ==="
cat > "$NGINX_CONF" <<'NGINX'
# VocaTa HTTPS 反向代理
# 前端: https://86.53.161.33 → localhost:3000
# 后端: https://86.53.161.33/api → localhost:9009
# WebSocket: wss://86.53.161.33/ws → localhost:9009

server {
listen 443 ssl;
server_name 86.53.161.33;

Comment thread scripts/setup-https.sh
Comment on lines +8 to +12
SSL_DIR="/etc/nginx/ssl"
NGINX_CONF="/etc/nginx/sites-available/vocata-https"

echo "=== 1. 生成自签 SSL 证书 ==="
mkdir -p "$SSL_DIR"
Comment thread scripts/setup-https.sh
-out "$SSL_DIR/vocata.crt" \
-subj "/C=CN/ST=Beijing/O=VocaTa/CN=$SERVER_IP" \
-addext "subjectAltName=IP:$SERVER_IP"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants