Nginx:未捕获的TypeError:无法读取未定义的属性“长度”

时间:2019-05-01 05:12:43

标签: javascript node.js nginx reverse-proxy

当我使用Nginx配置keyrock IDM时,出现了以下错误。这是在google chrome开发人员工具控制台上查看的。

handle_get_members.js:9 Uncaught TypeError: Cannot read property 'length' of undefined
    at Object.success (handle_get_members.js:9)
    at i (jquery-3.2.1.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-3.2.1.min.js:2)
    at A (jquery-3.2.1.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery-3.2.1.min.js:4)

这是在我使用Keyrock上的一种功能(列出成员)时提出的。

我的nginx conf文件如下所示:

 location /key/
        {
             proxy_set_header   X-Forwarded-Host    $host;
             proxy_set_header    Host                $host;
             proxy_set_header    X-Real-IP            $remote_addr;
             proxy_set_header    X-Forwarded-For        $proxy_add_x_forwarded_for;
             rewrite ^/key(/.*)$  $1 break;
             proxy_pass           https://Keyrock-Host:Keyrock-Port;
             proxy_redirect / /key/;
             sub_filter '="/' '="/key/';
             sub_filter '= "/' '= "/key/';
             sub_filter '=\'/' '=\'/key/';
             sub_filter_once off;
        }
    location /idm/
        {
             proxy_pass   https://Keyrock-Host:Keyrock-Port/idm/;
        }
    location /img/
        {
             proxy_pass   https://Keyrock-Host:Keyrock-Port/img/;
        }

以下是我面临的错误的快照。如果有人遇到过类似问题。


更新1:发表评论后

成员列表的网址为:/idm/organizations/589b97efe-d03c-122f-c522-3e557fa24a37

使用nginx访问它:/key/idm/organization/organizations

这是因为Fiware Keyrock后端中的代码是:

var url = '/idm/organizations/'+window.location.pathname.split('/')[3]

因此,从变量获取的值为3,该变量是组织形式,而不是其在nginx中的ID,因此无法提取。

enter image description here


更新2:

使用nginx访问文件后。 url的值如下所示:

enter image description here


更新3:

在google chrome开发工具的网络控制台中,同时预览管理员用户的个人资料部分,显示以下内容

enter image description here

0 个答案:

没有答案