Use Blob Objects for Download Links
Lightning Web Security (LWS) blocks the use of data: URIs in anchor links because that approach has various security issues. Use a blob: URI instead.
This example shows an approach to creating a dynamic plain text file download link that uses a data: URI. This approach requires allowing data: URIs generally, which is insecure.
Instead, create a Blob to hold the data, and use the blob: URL scheme to make it available for download.
data: URIs embed content directly inline as a URL. This creates several security risks that LWS blocks. A blob: URL is bound to the origin that created it — it inherits the page’s origin, and is subject to same-origin policy. This and other attributes make blob: a controlled, auditable mechanism for a legitimate use case (file downloads) without the open-ended risks of data:.