Embed Jupyterlab into an iframe

Hey guys, I’m trying to embed a jupyterlab instance into an iframe in my website.

This is the iframe in my website:

<body>
   <iframe src='http://localhost:8888' />
</body>

I’ve also added tornado_settings to the etc\jupyter\jupyter_notebook_config.d\jupyterlab.json file.

{
  "NotebookApp": {
    "nbserver_extensions": {
      "jupyterlab": true
    },
	"tornado_settings": {
    	"headers": {
         "Content-Security-Policy": "frame-ancestors self http://localhost:4200"
    	}
	}
  }
}

but I keep getting the error:

Refused to display 'http://localhost:8888/lab?' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".

Am I missing something?

Thanks in advance.

Hey

I think you need the simple quotes around self

Here’s what I have that works fine

c.NotebookApp.tornado_settings = {
    'headers': {
        'Content-Security-Policy': "frame-ancestors https://*.fun-mooc.fr https://magistere.education.fr https://deptinfo-ensip.univ-poitiers.fr/ 'self' ;",
    }
}
2 Likes