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:20:00 +03:00
parent 21ed8fd300
commit 712a058872
2 changed files with 18 additions and 4 deletions

View file

@ -212,8 +212,15 @@ class="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-6
<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"

View file

@ -314,8 +314,15 @@ class="p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-
<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"