How to solve cross-origin for embedded Discourse?

According to /admin/customize/embedding, I embed Discourse in my website.
Since dark mode is controlled via script (not using prefers-color-sheme), I need to access the iframe’s contentDocument. But due to cross-origin, the contentDocument cannot be accessed.
I think Discourse should be able to allow cross-origin.