mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
fix(site): allow microphone access for Web Speech API on agents page (#23046)
## Problem The `/agents` page has a voice input feature that uses the Web Speech API (`webkitSpeechRecognition`), but clicking the mic button always results in a `"not-allowed"` error — even when the browser has microphone permission granted. ## Root Cause The `secureHeaders()` function in `site/site.go` sets a `Permissions-Policy` header with `microphone=()`, which completely disables microphone access for the page at the HTTP level. This overrides any browser-level mic permission grants and causes the Web Speech API to immediately fire an `onerror` event with `error: "not-allowed"`. ## Fix Change `microphone=()` to `microphone=(self)`, which: - Allows the Coder origin itself to use the microphone (enabling the Web Speech API voice input) - Still blocks cross-origin iframes from accessing the microphone This is the minimal permission change needed — `(self)` is more restrictive than removing the policy entirely, maintaining the security intent of the original header. ## Testing 1. Navigate to `/agents` 2. Click the mic button in the chat input 3. Verify voice input works (browser will prompt for mic permission if not already granted) 4. Verify `Permissions-Policy` response header now shows `microphone=(self)` instead of `microphone=()` --------- Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
blink-so[bot]
parent
9d33c340ec
commit
67f5494665
+1
-1
@@ -612,7 +612,7 @@ func secureHeaders() *secure.Secure {
|
||||
"geolocation=()",
|
||||
"gyroscope=()",
|
||||
"magnetometer=()",
|
||||
"microphone=()",
|
||||
"microphone=(self)",
|
||||
"midi=()",
|
||||
"payment=()",
|
||||
"usb=()",
|
||||
|
||||
Reference in New Issue
Block a user