Jupyterlab behind nginx proxy with basic authentication fails

I’m using nginx to act as proxy for my jupyterhub with jupyterlab notebooks. However, when I enable basic authentication to restrict access to the server, my jupyterlab does not load properly. To cut short, access to the static files gives a 401 error in the web console. Disabling basic authentication gives me a working julpyterlab environment. If anyone can help?

Here’s my nginx config

map $http_upgrade $connection_upgrade {
    default  upgrade;
 }

server {
     listen 80;
     server_name <obfuscated>;

      include snippets/ssl.conf;
      include snippets/letsencrypt.conf;
      return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name <obfuscated>;

    ssl_certificate /etc/letsencrypt/live/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/chain.pem;
    include snippets/ssl.conf;
    include snippets/letsencrypt.conf;
    gzip on;
    gzip_types text/plain text/css text/js text/xml text/javascript application/javascript 


# Actual jupyterhub configuration
# Managing literal requests to the JupyterHub front end     
location / {
   proxy_pass http://127.0.0.1:8000;
   proxy_set_header Host $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Proto $scheme;
   proxy_set_header X-Real-IP $remote_addr;

   proxy_http_version 1.1;
   #proxy_redirect on;
   #proxy_buffering on;

   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection "upgrade";
   proxy_read_timeout 86400;

   auth_basic "Restricted Content";
   auth_basic_user_file /etc/nginx/passwd/passwd_jupyter;

}

}