Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with locally embedded file in Chrome #64

Closed
securisec opened this issue Jun 5, 2017 · 6 comments
Closed

Issue with locally embedded file in Chrome #64

securisec opened this issue Jun 5, 2017 · 6 comments
Labels

Comments

@securisec
Copy link

securisec commented Jun 5, 2017

Hi, is there a fix or a workaround to locally embedded files when opening in Chrome? Chrome and Safari both throws a XMLHttprequest cross origin error. I know the work around is to use a local webserver, but that seems a bit tedious...

Thanks!

@ku1ik
Copy link
Contributor

ku1ik commented Jul 17, 2017

Your page is opened via file:// protocol or the recording URL has file:// protocol?

@ku1ik ku1ik added the question label Jul 18, 2017
@securisec
Copy link
Author

securisec commented Jul 19, 2017

Hey @sickill . My page is being loaded with the file:// protocol. the css and js assets for asciinema are saved to local disk. The recording is saved to disk also. It can be assumed that I was testing this with the idea that i want it to load without internet. The issue only happens in chrome and safari, but not on firefox.

@ku1ik
Copy link
Contributor

ku1ik commented Jul 19, 2017

This is a limitation we can't easily overcome. I think it works in other browsers because they're less strict about security of such a setup.

Basically what happens is this: player makes XHR request from a page with file:// protocol to JSON URL also with file:// protocol. The protocols are the same but Chrome doesn't allow XHR requests for file:// protocol. As far as I know Chrome has some flags (or command line switch) that can enable this but I don't remember the details now.

@inakianduaga
Copy link

inakianduaga commented Oct 8, 2018

So, this is super old but I just run into this and figured out a fix using the data-uri spec to "inline" the json into the src attribute and avoid the CORS preflight.

Given a json file you want to play locally in an embedded file,

  1. base64 encode the json (using some online tool)
  2. use
<asciinema-player src="data:application/json;base64,BASE_64_ENCODED_JSON_HERE" />

will work on local files without needing to spin up a server.

@davidjeddy
Copy link

Wanted to confirm @inakianduaga solution works (though is missing a closing quote at the end of the src= property. Note, the Base64 encoded string must be placed INLINE, it can not be a linked file.

Thank you @inakianduaga .

@ku1ik
Copy link
Contributor

ku1ik commented Mar 17, 2019

Since we can't overcome the limitation of XHR requests, and there's solution (inline, base64 src) I'm gonna close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants