gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)

Home Page:https://gotify.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Copy to clipboard not working with http

ecker00 opened this issue · comments

Copy to clipboard does not work on http setup. For those who just use Gotify it on internal network/vpn/http, the browsers navigator.clipboard API is not available, so the copy to clipboard button does not work. I see this feature was added in pull request: #561

Solution

This would be solved if the fallback could use the old fashioned way, something like:

const temp = document.createElement('textarea');
temp.value = value;
document.body.appendChild(temp);
temp.select();
document.execCommand('copy');
document.body.removeChild(temp);

Here:

private copyToClipboard = async () => {
const {snackManager, value} = this.props;
try {
await navigator.clipboard.writeText(value);
snackManager.snack('Copied to clipboard');
} catch (error) {
console.error('Failed to copy to clipboard:', error);
snackManager.snack('Failed to copy to clipboard');
}
};

execCommand is deprecated. While it may work now, It likely breaks in the future. You should use https even if your inside internal network / vpn.