Buyrun hocam bu kodu kullanabilirsiniz
    <button type="button" onclick="copyCurrentUrl()">Kopyala</button>
    <script>
        function copyCurrentUrl() {
            
            var currentUrl = window.location.href;
            var copyText = document.queryCommandSupported('copy');
            var copyTextArea = document.createElement("textarea");
            copyTextArea.value = currentUrl;
            document.body.appendChild(copyTextArea);
            copyTextArea.select();
            try {
                var successful = document.execCommand('copy');
                var msg = successful ? 'Kopyalandı' : 'Kopyalanmadı';
                console.log(msg)

            } catch (err) {
                console.log('Bir hata oluştu');
            }
            document.body.removeChild(copyTextArea);
        }
    </script>