Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Angular 9 - run dev server with https #1633

@pablo95s

Description

@pablo95s

🐞 Bug report

What modules are related to this issue?

  • aspnetcore-engine
  • builders
  • common
  • express-engine
  • hapi-engine
  • module-map-ngfactory-loader

Is this a regression?

Yes, the previous version in which this bug was not present was version 8

Description

What's the right way to run dev server using https locally? In previous version it was possible to add 'fake' certificate to express in server.ts:

export const createServerForEnv = () => {
  if (process.env.ENVIRONMENT === 'dev') {
    return createHttpsServer({
      key: fs.readFileSync(path.resolve(__dirname, '../../../src/ssl/localhost.key')),
      cert: fs.readFileSync(path.resolve(__dirname, '../../../src/ssl/localhost.crt'))
    }, (req, res) => {
      requestListener(req, res);
    })
  } else {
    return createServer((req, res) => {
      requestListener(req, res);
    });
  }
}

const server = createServerForEnv();

server.listen(PORT, () => {
  console.log(`Server listening...`);
});

Now dev server is always running on http://localhost:4200 and it's not possible to change this. I am using npm run dev:ssr command which is for ng run app:serve-ssr script and @nguniversal/builders:ssr-dev-server as a builder

🔬 Minimal Reproduction

Run ng run app:serve-ssr script in basic angular universal repository.

🌍 Your Environment




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 9.1.3
Node: 13.10.1
OS: darwin x64

Angular: 9.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
Ivy Workspace: Yes

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.901.3
@angular-devkit/build-angular              0.901.3
@angular-devkit/build-optimizer            0.901.3
@angular-devkit/build-webpack              0.901.3
@angular-devkit/core                       9.1.3
@angular-devkit/schematics                 9.1.3
@angular/cdk                               9.2.1
@angular/http                              8.0.0-beta.10
@angular/material                          9.2.1
@angular/material-moment-adapter           9.2.1
@ngtools/webpack                           9.1.3
@nguniversal/builders                      9.1.0
@nguniversal/common                        9.1.0
@nguniversal/express-engine                9.1.0
@nguniversal/module-map-ngfactory-loader   8.1.1
@schematics/angular                        9.1.3
@schematics/update                         0.901.3
rxjs                                       6.5.5
typescript                                 3.8.3
webpack                                    4.42.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions