Skip to content

fix: add clipboard fallback for non-secure (HTTP) environments#274

Merged
butschster merged 1 commit intomasterfrom
fix/clipboard-fallback-http
Mar 31, 2026
Merged

fix: add clipboard fallback for non-secure (HTTP) environments#274
butschster merged 1 commit intomasterfrom
fix/clipboard-fallback-http

Conversation

@butschster
Copy link
Copy Markdown
Member

What

Adds a shared clipboard utility (src/shared/lib/clipboard.ts) with execCommand('copy') fallback for environments where navigator.clipboard API is unavailable (HTTP, non-secure contexts). Replaces all direct navigator.clipboard usages across 5 Vue components and the sf-dumper vendor script.

Why

The navigator.clipboard API requires a secure context (HTTPS). When Buggregator is served over plain HTTP (common in local dev or Docker setups), all copy/screenshot-to-clipboard operations fail silently.

How

  • copyTextToClipboard() — tries navigator.clipboard.writeText, falls back to a temporary <textarea> + execCommand('copy')
  • copyBlobToClipboard() — tries navigator.clipboard.write with ClipboardItem, falls back to copying a data URL as text
  • sf-dumper.js gets an inline fallback since it's vanilla JS

Testing

  • Serve the app over HTTP and verify copy buttons work (code snippets, payload copy, cURL copy, profiler function copy, screenshot copy)
  • Verify existing HTTPS behavior is unchanged

navigator.clipboard API requires a secure context (HTTPS) and fails
silently on plain HTTP. Added a shared clipboard utility with
execCommand('copy') fallback and replaced all direct navigator.clipboard
usages across Vue components and sf-dumper.
@butschster butschster added the bug Something isn't working label Mar 31, 2026
@butschster butschster self-assigned this Mar 31, 2026
@butschster butschster merged commit 4a26067 into master Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant