Not able to load the Jupyter notebook UI page Getting Error "EvalError"

I configured the JupyterHub Dockerspawner.
I am able to run the JUPYTERHUB container without any issues and able to spawn the jupyter notebook container as well.
Here the problem is having with the content-security-policy.
EvalError: Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source of script in the following Content Security Policy directive: “default-src ‘self’ ‘unsafe-inline’ https: data:”
Here I am attaching the console section in (DevTools) screenshot of jupyter notebook which is spawned up from the JupyterHub.

I tried with following configuration in jupyterhub_config.py:
c.JupyterHub.tornado_settings = {
** ‘headers’: {**
** ‘Content-Security-Policy’: “default-src ‘self’ * ‘unsafe-inline’ https: data: ‘unsafe-eval’;”**
** }**
}

Even though if I add this configuration I am still facing the same issue.
Can anyone please help me regarding this?

Since the error occurs with Jupyter Notebook the CSP configuration needs to be set in the notebook configuration file, not JupyterHub.

Thanks @manics for giving the suggestion.
I tried with the following configuration in jupyter_notebook_config.py file.
c.NotebookApp.tornado_settings={‘headers’: {‘Content-Security-Policy’: “default-src ‘self’ * ‘unsafe-inline’ ‘unsafe-eval’”}}

But still getting the same error:
EvalError: Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source of script in the following Content Security Policy directive: “default-src ‘self’ ‘unsafe-inline’ https: data:
Plugin ‘@jupyterlab/notebook-extension:kernel-status’ failed to activate.
Plugin ‘@jupyterlab/inspector-extension:notebooks’ failed to activate.
Like this all the libraries failed to activate.
Can you please suggest with the correct configuration either in jupyter_notebook_config.py or jupyter_server_config.py or provide any alternate solution for this?

It looks like you may be using curly/unicode open and close quotes- this often occurs if you copy and paste something, or if your editor autoformats quotes. Can you try using plain ("...", '...') quotes?

Can you show us what headers are being returned? This should be visible in the network tab of your browser console.

1 Like

Hi @manics
Browser Console Network Tab:

So all api’s response getting the 200(status code) but UI shows a blank page.

This is how I configured in jupyter_notebook_config.py file.
Attaching the screenshot.

And I am getting the Error in Browser console:

If the browser console network tab shows the expected Content-Security-Policy header but your browser is rejecting it perhaps there’s a syntax error or invalid parameter? This wouldn’t be related to JupyterHub, so if no-one else on this forum has a suggestion it could be worth asking on a web development forum instead?