openclaw - 💡(How to fix) Fix [Bug] Web UI 语音输入无法使用 - Content Security Policy 阻止 [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#52169Fetched 2026-04-08 01:14:49
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Timeline (top)
commented ×1
RAW_BUFFERClick to expand / collapse

问题描述

在 OpenClaw Web UI (http://127.0.0.1:18789) 中,自带的麦克风按钮无法正常工作。

环境

  • OpenClaw 版本: 2026.3.13
  • 浏览器: Chrome (Edge)
  • 操作系统: Windows 11 / WSL2

复现步骤

  1. 打开 OpenClaw Web UI
  2. 点击左下角的麦克风按钮
  3. 按住按钮说话

实际结果

浏览器控制台报错:

错误详情:

  • 问题出在 被 CSP 阻止
  • 这导致语音输入功能完全无法使用
  • 语音播放也被阻止

期望结果

用户应该能够:

  1. 通过麦克风按钮进行语音输入
  2. 听到 AI 的语音回复

额外信息

  • OpenClaw 源码中已包含 SpeechRecognition 和 speechSynthesis API 的实现
  • 问题似乎是 Gateway 的 CSP 设置过于严格
  • 手机端 app 不受影响(只有网页版有问题)

建议修复

  1. 在 Gateway 配置中添加语音相关的 CSP 放行
  2. 或者在网页端使用外部语音服务而非浏览器原生 API

extent analysis

Fix Plan

To resolve the issue with the microphone button in OpenClaw Web UI, we need to adjust the Content Security Policy (CSP) settings in the Gateway configuration. Here are the steps:

  • Step 1: Identify the necessary directives
    • We need to add the following directives to the CSP configuration:
      • media-src
      • script-src (for SpeechRecognition and speechSynthesis APIs)
  • Step 2: Update the Gateway configuration
    • Add the following lines to the CSP configuration file:

Content-Security-Policy: media-src 'self' https://example.com; Content-Security-Policy: script-src 'self' https://example.com;

  + Replace `https://example.com` with the actual domain or URL of the speech recognition and synthesis services.
* **Step 3: Test the changes**
  + Restart the Gateway service to apply the changes.
  + Open the OpenClaw Web UI and test the microphone button.

### Example Code
Here's an example of how to update the CSP configuration in a Node.js application using the `helmet` library:
```javascript
const helmet = require('helmet');

// ...

app.use(helmet.contentSecurityPolicy({
  directives: {
    mediaSrc: ["'self'", 'https://example.com'],
    scriptSrc: ["'self'", 'https://example.com'],
  },
}));

Verification

To verify that the fix worked, open the OpenClaw Web UI and test the microphone button. The browser console should no longer report any CSP-related errors, and the speech input and playback functionality should work as expected.

Extra Tips

  • Make sure to test the changes in different browsers and environments to ensure that the fix works consistently.
  • Consider using a more permissive CSP configuration during development and testing, and then tighten the settings for production.
  • Keep in mind that CSP settings can affect other features and functionality in the application, so be sure to test thoroughly after making changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING