1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular, Node API, How to SSL Localhost, DEPTH_ZERO_SELF_SIGNED_CERT, Cookie

Discussão em 'Angular' iniciado por Jeb50, Junho 15, 2025.

  1. Jeb50

    Jeb50 Guest

    LocalHost, Angular 11 (https://localhost:4200) and Node API (https://localhost:3001), both are using OpenSSL, browser is Chrome. To iron out Status: CORS error (due to diff ports) I follow this adding Proxy, got this in Angular's console


    [HPM] Error occurred while trying to proxy request /somewhere1 from localhost:4200 to https://localhost:3001 (DEPTH_ZERO_SELF_SIGNED_CERT) (https://nodejs.org/api/errors.html#errors_common_system_errors)
    ​

    Following didn't help:

    1. Confirmed the Chrome brought up by F5 has chrome://flags/#allow-insecure-localhost Enabled.
    2. Added process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; to Node API's server.js.

    Proxy.conf.json

    {
    "context":
    [
    "/path1",
    "/path2"
    ],
    "target" : "https://localhost:3001",
    "secure": true,
    "changeOrigin": true,
    "rejectUnauthorzied": false,
    "logLevel": "info"
    }


    angular.json

    "serve": {
    ...
    "options": {
    "browserTarget": "myapp:build",
    "ssl": true,
    "proxyConfig": "src/proxy.conf.json"


    Call API:

    private http: HttpClient;
    const httpOptions =
    {
    headers: new HttpHeaders({'Content-Type': 'application/json'}),
    rejectUnauthorized: false
    };
    this.http.post<any[]>("/somewhere1/hello", {}, httpOptions).subscribe


    Believe this is Angular end.

    Continue reading...

Compartilhe esta Página