nestjs / ng-universal

Angular Universal module for Nest framework (node.js) 🌷

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SSL issues when using httpOptions as stated in the documentation

yackinn opened this issue · comments


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using ssl on the dev server configuration and the Nestjs instance the request won't reach the server.

// main.ts
const httpsOptions = {
  key: fs.readFileSync(process.cwd() + '/storefront_app/config/server.key'),
  cert: fs.readFileSync(process.cwd() + '/storefront_app/config/server.crt')
};

async function bootstrap() {
  console.log(process.cwd() + '/storefront_app/config/server.crt');
  const app = await NestFactory.create(AppServerModule, {
    httpsOptions
  });
await app.listen(process.env.PORT || 4000);
...
}

// angular.json
...
"serve-ssr": {
          "builder": "@nguniversal/builders:ssr-dev-server",
          "options": {
            "ssl": true,
            "sslCert": "storefront_app/config/server.crt",
            "sslKey": "storefront_app/config/server.key",
            "browserTarget": "ui:build",
            "serverTarget": "server:build",
            "port": 4200,
            "host": "0.0.0.0"
          },

Expected behavior

The request should reach the server as it does wihtput using the httpOptions in the NestFactory.
When requesting a page using https and bootstrapping the Nest app instance without the httpOptions the request will reach the server as expected.

Minimal reproduction of the problem with instructions

We're following the instructions provided in this sample repository.
https://github.com/TrilonIO/universal-nest
When the app is configured as stated above the issue will occur.

What is the motivation / use case for changing the behavior?

We need the httpOptions to be able to use the push method on the response object.

Environment

Macos Big Sur 11.2.3 (20D91)


Nest version: 7.5.5

 
For Tooling issues:
- Node version: v14.17.1
- Platform:  Mac

Others: