来自NodeJ的JupyterLab代理无法满足特定请求

时间:2020-05-29 10:11:57

标签: node.js express proxy jupyter jupyter-lab

我正在尝试通过Node js代理JupyterLab。一切正常,但是当我单击创建任何笔记本时。对/jupyterLab/api/contents/的请求失败。


以下是一些详细信息:

节点版本-v9.4.0

JupyterLab版本-

     jupyter core     : 4.6.3
     jupyter-notebook : 5.7.9
     qtconsole        : 4.5.4
     ipython          : 5.8.0
     ipykernel        : 4.10.1
     jupyter client   : 5.3.4
     jupyter lab      : 0.33.12
     nbconvert        : 5.6.1
     ipywidgets       : 7.5.1
     nbformat         : 4.4.0
     traitlets        : 4.3.3

使用Express框架。 [Ref https://expressjs.com/en/starter/generator.html]

NodeJs代理程序包-http-proxy-middleware [Ref https://www.npmjs.com/package/http-proxy-middleware]

节点应用程序正在http://localhost:3001/

上运行

JupyterLab运行在http://localhost:8889/


节点代码

var express = require('express');
const { createProxyMiddleware } = require('http-proxy-middleware');
var app = express();

app.use('/jupyterLab/', createProxyMiddleware({
    target : "http://localhost:8889/",
    ws     : true
}));

module.exports = app;

JupyterLab配置

c.NotebookApp.open_browser = False
c.NotebookApp.port = 8889
c.NotebookApp.base_url = '/jupyterLab/'
c.NotebookApp.token = ''
c.NotebookApp.notebook_dir = "D:jupyterLab"
c.NotebookApp.allow_origin = '*'
c.NotebookApp.tornado_settings = {
    'headers': {
        'Content-Security-Policy': "frame-ancestors 'self' http://127.0.0.1:3001/ http://127.0.0.1:3001/* http://localhost:3001/ http://localhost:3001/*",
    }
}

HTML-方法1

<!-- Without proxy, it works perfectly fine. But Node isn't involved here. -->
<iframe 
    src    = "http://localhost:8889/jupyterLab/"
    height = "400px"
    width  = "100%"
></iframe>
[![Screenshot -> Without proxy][1]][1]

HTML-方法2 <-目标。

<!--  With proxy, Works fine, but when we click on Notebook, an API call happens, which stays in pending state for 2-4 min and then fails. -->
<iframe 
    src    = "/jupyterLab/"
    height = "400px"
    width  = "100%"
></iframe>
[![With Proxi - API failing][1]][1]

0 个答案:

没有答案