Hi Andrey (and the sage-cell list),
I was just demoing the Sage cell server, and hit a confusing issue:
If you use an interact at
https://sagecell.sagemath.org/ like this
then it works fine:
@interact
def f(n=2020):
print(factor(n))
But if you embed an interact in a "random" static site via the simple
directions, then it is completely broken (email will probably mangle
this, but you get the point, and I also attached a screenshot). By
"broken" I mean that there is a spinner forever and no output appears:
<script src="
https://sagecell.sagemath.org/static/embedded_sagecell.js"></script>
<script>sagecell.makeSagecell({"inputLocation": ".sage"});</script>
<div class="sage">
<script type="text/x-sage">
@interact
def f(n=2020):
print(factor(n))
</script>
</div>
The interacts at
https://wiki.sagemath.org/interact *do* work though.
If you expand a sage cell at
http://linear.ups.edu/html/section-SSLE.html then try to put an
interact in it, that also does NOT work.
Of course, actually looking at the console log reveals the problem:
Access to XMLHttpRequest at
'
https://sagecell.sagemath.org/kernel?CellSessionID=7dce1ecb762c41868c96f9af39df6ea8&timeout=0&accepted_tos=true'
from origin '
https://cocalc.com' has been blocked by CORS policy:
Request header field x-xsrftoken is not allowed by
Access-Control-Allow-Headers in preflight response.
So to get widgets to work with the sagecell server, I have to
configure the site hosting my static html to allow certain types of
cross domain access that is denied by default. That's all fine and
good, but...
(1) is there anything documented anywhere about issues with CORS +
sagecell server? I googled and could find absolutely nothing at all,
and no issues in the sagecell issue tracker.
(2) Wouldn't it be nice if instead of the output just spinning forever
and things being broken, the client sagecell could say "sorry, widgets
are not available due to the CORS policy of the hosting website.
Please see this link for more details...." or something like that?
Just curious if this has come up before, or should I create a ticket at
https://github.com/sagemath/sagecell/issues
?
--
William (
http://wstein.org)