1

我想为我的应用程序设置基本路径。我更新了

await app.restServer.basePath('/api/v1');   

在我"index.js"的项目根文件夹中。但是当我尝试访问资源管理器时,将错误抛出为"Cant get explorer"

    await app.basePath('/api/v1'); 
       await app.restServer.basePath('/api/v1');
     this.static('/', path.join(__dirname, '../public'));
this.bind(RestBindings.SequenceActions.SEND).toProvider(Validateprovider);
        this.bind(RestExplorerBindings.CONFIG).to({
          path: path.resolve('/explorer'),
        });

加载应用程序后,可以访问此 URL: http: //127.0.0.1 :8020/api/v1 但是当我单击同一页面中的资源管理器时。它没有重定向到资源管理器,而是给出错误

“无法获取 /explorer/”

请让我知道如何使用我提到的前缀访问资源管理器。

4

2 回答 2

2

问题可能是,/publix/index.html指向资源管理器的链接没有改变,它指向/explorer. 更改基本路径后,您应该将此链接更改为{your new base path}/explorer. 更改应用程序中的基本路径不会更新静态资源。基本上,index.html你应该有:

<h3>API Explorer: <a href="/api/v1/explorer">/explorer</a></h3>

然后它会工作

于 2019-12-05T14:38:32.563 回答
1

您需要在 application.ts 中执行此操作。

this.bind(RestExplorerBindings.CONFIG).to({
  path: '/api/v1',
});

有关更多详细信息,您可以参考此处的文档。

于 2019-05-28T10:15:50.160 回答