rrweb-io / rrweb-snapshot

rrweb's snapshot and rebuild module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

styleSheets.cssRules have CORS problem

xyj404 opened this issue · comments

commented

We set _cssText attributes to Node. But there is CORS problem when css file is from other domain. So It's not complete inlineStylesheet. It's a problem when I want to get record with history css file.

I suggest that we can get these file content by xhr request. And set it to _cssText.

The main problem in terms of playback is:

  • recording cannot exist standalone w.r.t. styles as it references them rather than inlines them (this is also the case with e.g. fonts)
  • the :hover -> .\:hover rewrite does not take place, so e.g. dropdown menus etc. on websites don't appear

We are planning to solve it separately by rewriting the URLs to e.g. https://playbackdomain.example.com/www/3rdparty/example.org/original-3rd-party-css-file.css and proxying those CSS files in order to do the hover rewrite. I think an extra xhr request is unacceptable for our usecase (as it generates extra traffic for the end user), so if such a solution were developed, we'd need to be able to turn it off.

commented

@eoghanmurray is right, some solution like this should happen in the backend when you got the recorded session.

@xyj404 I haven't looked into it, but did you check whether the XHR request would in fact be able to by-pass the CORS restrictions?
Also it would be much more attractive if the XHR request could be made re-use caches so no new network activity was generated (I'd say that's pretty hard though).