The async Clipboard API (navigator.clipboard) is only exposed in secure
contexts — HTTPS, or localhost. An admin UI served over plain HTTP on an
IP has no clipboard object at all, so a bare
navigator.clipboard.writeText(...) throws
Cannot read properties of undefined (reading 'writeText') rather than
failing in any way the caller can act on.
The legacy document.execCommand('copy') path is not gated that way and
still works there, so it is tried before giving up. It is deprecated, but it
is the only thing standing between a plain-HTTP admin origin and a copy
button that cannot copy.
Copying text without assuming a secure context.
The async Clipboard API (
navigator.clipboard) is only exposed in secure contexts — HTTPS, orlocalhost. An admin UI served over plain HTTP on an IP has noclipboardobject at all, so a barenavigator.clipboard.writeText(...)throwsCannot read properties of undefined (reading 'writeText')rather than failing in any way the caller can act on.The legacy
document.execCommand('copy')path is not gated that way and still works there, so it is tried before giving up. It is deprecated, but it is the only thing standing between a plain-HTTP admin origin and a copy button that cannot copy.