fix(logs): handle missing clipboard API in non-HTTPS contexts

navigator.clipboard is undefined in insecure contexts (HTTP), causing
a silent TypeError when clicking the copy logs button. Added a secure
context check and proper Promise chaining so failures surface as user-
visible error messages instead of silent crashes.

Affects deployment log view and shared get-logs component.
This commit is contained in:
Devrim Tunçer
2026-03-12 23:24:02 +03:00
parent 21ed8fd300
commit 712a058872
2 changed files with 18 additions and 4 deletions
@@ -212,8 +212,15 @@
<button
x-on:click="
$wire.copyLogs().then(logs => {
navigator.clipboard.writeText(logs);
Livewire.dispatch('success', ['Logs copied to clipboard.']);
if (!navigator.clipboard) {
Livewire.dispatch('error', ['Clipboard is not available. Please use HTTPS.']);
return;
}
navigator.clipboard.writeText(logs).then(() => {
Livewire.dispatch('success', ['Logs copied to clipboard.']);
}).catch(() => {
Livewire.dispatch('error', ['Failed to copy logs to clipboard.']);
});
});
"
title="Copy Logs"
@@ -314,8 +314,15 @@
<button
x-on:click="
$wire.copyLogs().then(logs => {
navigator.clipboard.writeText(logs);
Livewire.dispatch('success', ['Logs copied to clipboard.']);
if (!navigator.clipboard) {
Livewire.dispatch('error', ['Clipboard is not available. Please use HTTPS.']);
return;
}
navigator.clipboard.writeText(logs).then(() => {
Livewire.dispatch('success', ['Logs copied to clipboard.']);
}).catch(() => {
Livewire.dispatch('error', ['Failed to copy logs to clipboard.']);
});
});
"
title="Copy Logs"