From 55e260b39226c1d252b45ebd7ea2580b736fc8d7 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Mon, 23 Mar 2026 22:39:55 -0400 Subject: [PATCH] fix(settings): fallback clipboard copy for http dev environments navigator.clipboard.writeText() requires a secure context (HTTPS) and silently fails on http://. Add an execCommand fallback so the API key copy button works on non-secure dev instances. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/views/SettingsView.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/SettingsView.vue b/frontend/src/views/SettingsView.vue index 2d7e33d..4d58272 100644 --- a/frontend/src/views/SettingsView.vue +++ b/frontend/src/views/SettingsView.vue @@ -89,7 +89,20 @@ async function revokeApiKey(id: number) { } async function copyApiKey() { - await navigator.clipboard.writeText(newKeyValue.value); + try { + await navigator.clipboard.writeText(newKeyValue.value); + } catch { + // Fallback for http (non-secure) contexts where clipboard API is unavailable + const ta = document.createElement('textarea'); + ta.value = newKeyValue.value; + ta.style.position = 'fixed'; + ta.style.opacity = '0'; + document.body.appendChild(ta); + ta.focus(); + ta.select(); + document.execCommand('copy'); + document.body.removeChild(ta); + } apiKeyCopied.value = true; setTimeout(() => { apiKeyCopied.value = false; }, 2000); }