The issue at hand arises from attempting to execute a script utilizing XMLHttpRequest
within a local HTML file in your browser. Upon checking the browser console, an error will be displayed as it struggles to locate files within all src
/href
tags. To address this, removing the initial /
from each src
/href
tag would allow the player to load; however, this would lead to CORS issues when the script accesses your cast file.
An effective solution involves employing an HTTP server to host your cast files. This enables direct referencing using their complete server path, such as
http://localhost:3000/asciinema/demo.cast
. Alternatively, you can utilize an external URL for the cast file, provided that the external site has CORS disabled. For instance:
<asciinema-player src="https://asciinema.org/a/28307.cast"></asciinema-player>
The choice of HTTP server is up to you, as there are numerous user-friendly servers available across various programming languages. Consider tools like http-server
for Node/JavaScript enthusiasts or simplehttpserver
for those familiar with Python. Opt for the option you find most comfortable.
Another "solution" could involve disabling CORS in your browser. However, this approach poses security risks and is merely a temporary workaround.
In essence, loading local cast files within local HTML files is impeded by CORS restrictions. The recommended course of action is hosting your casts on either a local or external HTTP server.