Copy command does not work after build and deployment ​
The Copy command uses useClipboard to copy content to the clipboard.
Clipboard API Compatibility ​
- Clipboard APIs (such as
navigator.clipboard) are only available in some browsers when running underHTTPSor onlocalhost. - If you access your site via
HTTPafter deployment, many modern browsers will disable the clipboard API, causingisSupported.valueto befalse.
Recommendations ​
- Ensure you are using
HTTPS: Configure your site to useHTTPS, as most browsers only enable the clipboard API underHTTPS. - Check browser compatibility: Make sure your browser version supports the clipboard API. You can check compatibility on the MDN documentation.
- Differences between local development and production: Local development usually runs on
localhost, where browsers relax security restrictions. In production, if not usingHTTPS, the API will not be available.
Temporary Solution ​
- If you cannot use
HTTPSfor now, consider falling back todocument.execCommand('copy')as a compatibility solution. However, this method is deprecated and may not be available in the future.
nuyoah