Reputation: 1010
I want to run an IPython notebook that is on my server inside an iframe on another server. I get this error:
Refused to display 'my_url/Test.ipynb' in a frame because
it set 'X-Frame-Options' to 'SAMEORIGIN'
Here it says I should set some x-frame-header option for this: http://ipython.org/ipython-doc/dev/whatsnew/development.html#iframe-embedding
Where can I set this? How to change this X-Frame-Option so that it can be embedded from another site? :)
Upvotes: 6
Views: 4760
Reputation: 1010
Update
According to the answer by @simon (https://stackoverflow.com/a/75358222/1469195), you should nowadays add the following to the ipython_notebook_config.py
c.NotebookApp.tornado_settings = {
'headers': {
'Content-Security-Policy': "frame-ancestors https://mywebsite.example.com 'self' "
}
}
Prior Update
according to the comment by Harrison, it should be
c.NotebookApp.tornado_settings = {'headers': {'X-Frame-Options': 'ALLOW-FROM https://example.com/'}}
now, see also http://jupyter-notebook.readthedocs.io/en/stable/config.html
Original Post
Ok I found a solution that is working but I am not 100% sure if it is the right way to do it: In .ipython/your_profile/ipython_notebook_config.py add
c.NotebookApp.webapp_settings = {'headers': {'X-Frame-Options': 'ALLOW-FROM https://example.com/'}}
Works for me, but not sure if this overrides more settings from tornado or anything :)
Upvotes: 3
Reputation: 31
I tried and the answer doesn't work now. The sugestion in the https://jupyter-notebook.readthedocs.io/en/stable/public_server.html#embedding-the-notebook-in-another-website work for me. Add the following to the ipython_notebook_config.py
c.NotebookApp.tornado_settings = {
'headers': {
'Content-Security-Policy': "frame-ancestors https://mywebsite.example.com 'self' "
}
}
Upvotes: 0
Reputation: 3755
an easy way is to use the "cell magic" %%html
to embed an iframe into jupyter cell
example:
%%html
<iframe width="500" height="350" src="https://www.youtube.com/embed/vTingdk_pVM" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
Upvotes: -1