【问题标题】:Enable SSL in Loopback 4在 Loopback 4 中启用 SSL
【发布时间】:2020-06-13 20:01:27
【问题描述】:

我尝试在我的文件 application.ts 中调整来自 https://loopback.io/doc/en/lb4/Server.html 的代码

this.bootOptions = {
      controllers: {
        // Customize ControllerBooter Conventions here
        dirs: ['controllers'],
        extensions: ['.controller.js'],
        nested: true,
      },
      rest: {
        protocol: 'https',
        key: fs.readFileSync('./cert/my-site.com.key'),
        cert: fs.readFileSync('./cert/my-site.com.crt'),
      }
    };

访问控制器 API 时遇到问题 尝试 nmap 查看打开的端口和 curl,但似乎没有任何东西可以用作 https

【问题讨论】:

    标签: node.js loopback


    【解决方案1】:

    终于找到答案了

    SSL 设置应按原样在 index.ts 中设置

    export async function main(options: ApplicationConfig = {}) {
    
      const optionssl = {
        rest: {
          protocol: 'https',
          key: fs.readFileSync('./cert/my-site.com.key'),
          cert: fs.readFileSync('./cert/my-site.com.crt'),
        }
      };
    
      const app = new MyApplication(optionssl);
    

    application.ts 不应更改

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-15
      • 1970-01-01
      • 2019-11-17
      • 2016-08-26
      • 2022-11-23
      • 2012-10-13
      • 2020-10-04
      • 2023-04-03
      相关资源
      最近更新 更多