apaul
apaul

Reputation: 127

Angular proxy.conf, secure:false stops the request from going, Angular CLI bug?

I have a proxy conf file setup. I am at a complete loss no idea what is going on after a day of Googling.

{
  "/auth/*": {
      "target": "https://auth-group-qa.company.io/",
      "pathRewrite": {
        "^/auth": ""
      },
      "secure": false
  },
  "changeOrigin": true,
  "logLevel": "debug"
}

This is my Angular JSON-

"serve": {
  "builder": "@angular-devkit/build-angular:dev-server",
  "options": {
    "browserTarget": "company-syntese:build",
    "proxyConfig": "proxy.conf.json"
  },

With the secure being true in the json file I get this (using --verbose) -

[webpack-dev-server] [HPM] Error occurred while proxying request localhost:4200/access-management/v1 to https://auth-group-qa.company.io/ [ERR_TLS_CERT_ALTNAME_INVALID] (https://nodejs.org/api/errors.html#errors_common_system_errors)

With secure: false there is no request to the proxy-

headers: HttpHeaders, status: 404, statusText: 'Not Found', url: 'http://localhost:4200/auth/access-management/v1', ok: false,

Code to call service-

onSubmit(form: FormGroup) {
    this.http.postRequest('/auth/access-management/v1', form.value, this.headers).subscribe(
      (data) => {
        console.log(data);
      },
      (error) => {
        console.log(error);
      }
    );
  }

Here is my package json-

  "dependencies": {
    "@angular/animations": "^13.2.0",
    "@angular/cdk": "^13.2.0",
    "@angular/common": "~13.2.0",
    "@angular/compiler": "~13.2.0",
    "@angular/core": "~13.2.0",
    "@angular/flex-layout": "^13.0.0-beta.36",
    "@angular/forms": "~13.2.0",
    "@angular/localize": "^13.2.0",
    "@angular/material": "^13.2.0",
    "@angular/platform-browser": "~13.2.0",
    "@angular/platform-browser-dynamic": "~13.2.0",
    "@angular/router": "~13.2.0",
    "@auth0/angular-jwt": "^5.0.2",
    "@datorama/akita": "^7.1.1",
    "@fortawesome/fontawesome-free": "^5.15.4",
    "@ng-bootstrap/ng-bootstrap": "^11.0.0",
    "@ng-select/ng-select": "^8.1.1",
    "@ngx-translate/core": "^14.0.0",
    "@ngx-translate/http-loader": "^7.0.0",
    "@popperjs/core": "^2.11.2",
    "@schematics/angular": "^13.2.0",
    "angular-highcharts": "^13.0.1",
    "array-uniq": "^3.0.0",
    "bootstrap": "^5.1.3",
    "bootstrap-icons": "*",
    "core-js": "^3.20.3",
    "file-saver": "^2.0.5",
    "highcharts": "^9.3.2",
    "jsonwebtoken": "^8.5.1",
    "mixpanel-browser": "^2.43.0",
    "moment": "^2.29.1",
    "ng-click-outside": "^9.0.1",
    "ng-multiselect-dropdown": "^0.3.8",
    "ngx-logger": "^5.0.7",
    "pako": "^2.0.4",
    "rxjs": "~7.5.2",
    "tslib": "^2.3.1",
    "uuid": "^8.3.2",
    "xlsx": "^0.17.5",
    "zone.js": "~0.11.4"
  },

Upvotes: 1

Views: 687

Answers (1)

apaul
apaul

Reputation: 127

I have this fixed. The issue is that the newer Angular-CLI doesn't show a log all the time. A new project in Angular 11 revealed it's a server error not a front end error.

Upvotes: 1

Related Questions