angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.72k stars 11.98k forks source link

Locally running a build > all network requests' request URL's are host url #23838

Closed jacobjohn-transitiv closed 2 years ago

jacobjohn-transitiv commented 2 years ago

🐞 Bug report

Command (mark with an x)

Is this a regression?

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

Description

After updating our angular app from 9 to 14, stepwise, and fixing all the compilation errors, I was finally able to compile and run the app locally with ng serve. All network requests are functioning and pointed at the correct endpoints. When I build the app with npm run build which is "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --configuration production --base-href /app/ && npm run post-build" and serve it locally, it appears that all my network requests request url's are being replaced with the host url. For example, my login endpoint should be https://requestapi.com/login but every single api call has a request url as http://localhost:4000/. That's it, nothing append to the end of the url or anything. All the network requests work perfectly when I just do ng serve.

πŸ”¬ Minimal Reproduction

package.json


{
  "name": "appname-frontend",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng serve",
    "start-test": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng run appname-frontend:serve-coverage",
    "start-lighthouse": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng serve -c test",
    "build": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --configuration production --base-href /app/ && npm run post-build",
    "test": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng test",
    "test:tc": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng test --watch=false --source-map=false --code-coverage",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "e2e:ci": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng run appname-frontend-e2e:e2e-ci",
    "e2e:coverage": "npx nyc report --reporter=lcov --reporter=text-summary",
    "serve-coverage": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng run appname-frontend:serve-coverage",
    "ngcc": "ngcc",
    "lighthouse:ci": "lhci autorun",
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors",
    "cypress:browserstack:start": "browserstack-cypress run",
    "cypress:open": "./node_modules/cypress/bin/cypress open",
    "cypress:r": "node run-cypress.js",
    "cypress:run": "cypress run --record --key 6178512f-732c-46dc-9b45-db19c83f5792",
    "cypress:ci": "run-p --race start-test cypress:r",
    "fix-memory-limit": "cross-env LIMIT=2048 increase-memory-limit",
    "ng-high-memory": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng",
    "post-build": "node ./build/post-build.js",
    "build:ssr_bak": "npm run build:client-and-server-bundles && npm run post-build && npm run webpack:server",
    "serve:ssr_bak": "node dist/server",
    "build:client-and-server-bundles_bak": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --configuration production --base-href /app/ && node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng run appname-frontend:server",
    "dev:ssr": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng run appname-frontend:serve-ssr",
    "serve:ssr": "node dist/server/main.js",
    "build:ssr": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --configuration production --base-href / && npm run post-build && node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng run appname-frontend:server:production",
    "prerender": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng run appname-frontend:prerender",
    "postinstall": "ngcc",
    "deploy": "docker-compose up --build || true",
    "compodoc": "node --max_old_space_size=8000 ./node_modules/@compodoc/compodoc/bin/index-cli.js -p tsconfig.json"
  },
  "browserslist": [
    "> 0.5%",
    "last 2 versions",
    "Firefox ESR",
    "not dead",
    "not IE 9-11"
  ],
  "engines": {
    "node": "10.19.0"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^14.1.3",
    "@angular/cdk": "^14.1.3",
    "@angular/common": "^14.1.3",
    "@angular/compiler": "^14.1.3",
    "@angular/core": "^14.1.3",
    "@angular/flex-layout": "14.0.0-beta.40",
    "@angular/forms": "^14.1.3",
    "@angular/localize": "^14.1.3",
    "@angular/material": "^14.1.3",
    "@angular/platform-browser": "^14.1.3",
    "@angular/platform-browser-dynamic": "^14.1.3",
    "@angular/platform-server": "^14.1.3",
    "@angular/router": "^14.1.3",
    "@angular/upgrade": "^14.1.3",
    "@fullcalendar/core": "^4.4.2",
    "@fullstory/browser": "^1.4.5",
    "@gorniv/ngx-universal": "^2.2.2",
    "@highcharts/map-collection": "^1.1.3",
    "@microsoft/signalr": "^5.0.0-rc.1.20451.17",
    "@ng-bootstrap/ng-bootstrap": "^13",
    "@ng-matero/extensions": "^14.1.0",
    "@ngrx/data": "^14",
    "@ngrx/effects": "^14",
    "@ngrx/entity": "^14",
    "@ngrx/store": "^14",
    "@ngrx/store-devtools": "^14",
    "@nguniversal/express-engine": "^14",
    "@popperjs/core": "^2.11.6",
    "@sentry/angular": "^7.11.1",
    "@sentry/fullstory": "^1.1.5",
    "@sentry/tracing": "^7",
    "@stripe/stripe-js": "^1.16.0",
    "@syncfusion/ej2-angular-base": "^20.2.45",
    "@syncfusion/ej2-angular-buttons": "^20.2.45",
    "@syncfusion/ej2-angular-dropdowns": "^20.2.45",
    "@syncfusion/ej2-angular-grids": "^20.2.45",
    "@syncfusion/ej2-angular-inputs": "^20.2.45",
    "@syncfusion/ej2-angular-lists": "^20.2.45",
    "@syncfusion/ej2-angular-navigations": "^20.2.45",
    "@syncfusion/ej2-angular-querybuilder": "^20.2.45",
    "@types/file-saver": "^2.0.1",
    "@types/moment-duration-format": "^2.2.2",
    "@types/numeral": "0.0.26",
    "@types/request": "^2.48.5",
    "@types/stripe-v3": "^3.1.25",
    "@uirouter/angular": "^9.1.0",
    "@uirouter/core": "^6.0.6",
    "@uirouter/rx": "^0.6.5",
    "angular-file": "2.0.0",
    "angular-tree-component": "^8.5.6",
    "assert": "^2.0.0",
    "chart.js": "^2.9.3",
    "compression": "^1.7.4",
    "cookie-parser": "^1.4.5",
    "core-js": "^3.6.5",
    "d3": "^5.16.0",
    "domino": "^2.1.6",
    "express": "^4.17.1",
    "file-saver": "^2.0.2",
    "font-awesome": "^4.7.0",
    "fullcalendar": "^3.10.2",
    "highcharts": "^8.2.0",
    "https-proxy-agent": "^2.2.4",
    "i": "^0.3.7",
    "increase-memory-limit": "^1.0.7",
    "jquery": "^3.5.1",
    "js-marker-clusterer": "^1.0.0",
    "karma-coverage": "~2.0.3",
    "karma-junit-reporter": "^2.0.1",
    "launchdarkly-js-client-sdk": "^2.19.2",
    "less": "^3.12.2",
    "lodash": "^4.17.20",
    "log4js": "^3.0.6",
    "moment": "^2.29.1",
    "moment-duration-format": "^2.3.2",
    "morgan": "^1.10.0",
    "nanoscroller": "0.8.7",
    "ng-editable-table": "^0.3.15",
    "ngx-clipboard": "^13.0.1",
    "ngx-color-picker": "^11.0.0",
    "ngx-loggly-logger": "^6.0.0",
    "ngx-mask": "^12.0.0",
    "ngx-mat-select-search": "^4.2.1",
    "ngx-monaco-editor": "^8.0.0",
    "ngx-order-pipe": "^2.1.0",
    "ngx-papaparse": "^5.0.0",
    "ngx-toastr": "^14.3.0",
    "ngx-window-token": "^5.0.0",
    "npm": "^8.1.3",
    "numeral": "^2.0.6",
    "primeicons": "^2.0.0",
    "quill": "^1.3.7",
    "rxjs": "~7.5.0",
    "sass": "^1.54.4",
    "save": "^2.4.0",
    "terraformer-wkt-parser": "^1.2.1",
    "ts-loader": "8.0.14",
    "tslib": "^2.3.0",
    "winston": "^3.3.3",
    "winston-loggly-bulk": "^2.0.3",
    "xstate": "^4.13.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.2.1",
    "@angular-devkit/core": "^14.2.1",
    "@angular-devkit/schematics": "^14.2.1",
    "@angular/cli": "^14.1.3",
    "@angular/compiler-cli": "^14.1.3",
    "@angular/language-service": "^14.1.3",
    "@briebug/cypress-schematic": "^4.3.0",
    "@compodoc/compodoc": "^1.1.18",
    "@cypress/code-coverage": "^3.9.2",
    "@cypress/webpack-preprocessor": "^5.5.0",
    "@istanbuljs/nyc-config-typescript": "^1.0.1",
    "@lhci/cli": "^0.9.0",
    "@nguniversal/builders": "^14.1.0",
    "@types/angular": "^1.7.3",
    "@types/angular-ui-router": "^1.1.37",
    "@types/compression": "^1.7.0",
    "@types/cookie-parser": "^1.4.2",
    "@types/d3": "^5.16.4",
    "@types/d3-geo": "^1.12.1",
    "@types/express": "^4.17.8",
    "@types/geojson": "^7946.0.7",
    "@types/google.maps": "^3.43.3",
    "@types/highcharts": "^5.0.44",
    "@types/jasmine": "~4.0.0",
    "@types/jasminewd2": "^2.0.8",
    "@types/jquery": "^3.5.2",
    "@types/lodash": "^4.14.161",
    "@types/node": "^14.15.0",
    "@types/node-fetch": "^2.5.7",
    "@types/quill": "^2.0.4",
    "angular2-template-loader": "^0.6.2",
    "codelyzer": "^6.0.0",
    "concurrently": "^5.3.0",
    "cypress": "^6.9.1",
    "cypress-multi-reporters": "^1.4.0",
    "cypress-social-logins": "^1.6.0",
    "electron": "^8.5.2",
    "gulp": "^4.0.2",
    "gulp-concat": "2.6.1",
    "gulp-minify-css": "1.2.4",
    "gulp-rename": "1.3.0",
    "gulp-sourcemaps": "^2.6.5",
    "gulp-uglify": "3.0.0",
    "istanbul-instrumenter-loader": "^3.0.1",
    "istanbul-lib-coverage": "^3.0.0",
    "jasmine-core": "~4.3.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-cli": "2.0.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "karma-phantomjs-launcher": "^1.0.4",
    "karma-teamcity-reporter": "^1.1.0",
    "mocha-junit-reporter": "^2.0.0",
    "ng-mocks": "^14.1.3",
    "ngx-build-plus": "^11.0.0",
    "node-fetch": "^2.6.1",
    "npm-run-all": "^4.1.5",
    "nyc": "^15.1.0",
    "prettier": "2.0.5",
    "protractor": "~7.0.0",
    "puppeteer": "^5.5.0",
    "regexp-replace-loader": "^1.0.1",
    "source-map-support": "^0.5.19",
    "start-server-and-test": "^1.11.5",
    "ts-loader": "8.0.14",
    "ts-node": "^7.0.1",
    "tslint": "~6.1.0",
    "typescript": "4.6.4",
    "wallaby-webpack": "3.9.9",
    "webpack-cli": "^3.3.12"
  }
}

angular.json

{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"appname-frontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/browser",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.png",
{
"glob": "/*",
"input": "../node_modules/ngx-monaco-editor/assets/monaco",
"output": "./assets/monaco/min"
}
],
"styles": [
"node_modules/font-awesome/css/font-awesome.min.css",
"src/assets/theme/primeng-omega-theme.css",
"src/assets/theme/primeng.min.css",
"node_modules/primeicons/primeicons.css",
"node_modules/fullcalendar/dist/fullcalendar.min.css",
"node_modules/quill/dist/quill.snow.css",
"node_modules/nanoscroller/bin/css/nanoscroller.css",
{
"input": "src/custom-theme.scss",
"inject": true
},
"src/styles2.scss",
"node_modules/ngx-toastr/toastr.css",
"src/styles.css",
"src/app.scss"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/nanoscroller/bin/javascripts/jquery.nanoscroller.js",
"node_modules/moment/moment.js",
"node_modules/chart.js/dist/Chart.js",
"node_modules/fullcalendar/dist/fullcalendar.js",
"node_modules/quill/dist/quill.js",
"../../libs/react-component/main.min.js"
],
"aot": false,
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"sourceMap": true,
"optimization": false,
"namedChunks": true
},
"configurations": {
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.e2e.ts"
}
]
},
"coverage": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.e2e.ts"
}
]
},
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"optimization": true,
"outputHashing": "all",
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
},
"defaultConfiguration": ""
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "appname-frontend:build"
},
"configurations": {
"production": {
"browserTarget": "appname-frontend:build:production"
},
"test": {
"browserTarget": "appname-frontend:build:test"
}
}
},
"serve-coverage": {
"builder": "ngx-build-plus:dev-server",
"options": {
"browserTarget": "appname-frontend:build:coverage",
"extraWebpackConfig": "./cypress/coverage.webpack.js"
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"main": "server.ts",
"tsConfig": "src/tsconfig.server.json",
"sourceMap": true,
"optimization": false
},
"configurations": {
"dev": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.ts"
}
],
"optimization": true
},
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.e2e.ts"
}
],
"optimization": true
},
"production": {
"optimization": true,
"outputHashing": "none",
"namedChunks": false,
"extractLicenses": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
},
"defaultConfiguration": ""
},
"build-dev": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "www",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.png",
{
"glob": "*/",
"input": "../node_modules/ngx-monaco-editor/assets/monaco",
"output": "./assets/monaco/min/"
}
],
"styles": [
"node_modules/font-awesome/css/font-awesome.min.css",
"src/assets/theme/primeng-omega-theme.css",
"src/assets/theme/primeng.min.css",
"node_modules/primeicons/primeicons.css",
"node_modules/fullcalendar/dist/fullcalendar.min.css",
"node_modules/quill/dist/quill.snow.css",
"node_modules/nanoscroller/bin/css/nanoscroller.css",
{
"input": "src/custom-theme.scss",
"inject": true
},
"src/styles2.scss",
"node_modules/ngx-toastr/toastr.css",
"src/styles.css",
"src/app.scss"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/nanoscroller/bin/javascripts/jquery.nanoscroller.js",
"node_modules/moment/moment.js",
"node_modules/chart.js/dist/Chart.js",
"node_modules/fullcalendar/dist/fullcalendar.js",
"node_modules/quill/dist/quill.js",
"../../libs/react-component/main.min.js"
],
"aot": false,
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"sourceMap": true,
"optimization": false,
"namedChunks": true
},
"configurations": {
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.e2e.ts"
}
],
"optimization": true
},
"coverage": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.e2e.ts"
}
],
"optimization": true
},
"production": {
"optimization": true,
"outputHashing": "all",
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
},
"defaultConfiguration": ""
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "appname-frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"codeCoverage": true,
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/nanoscroller/bin/javascripts/jquery.nanoscroller.js",
"node_modules/moment/moment.js",
"node_modules/chart.js/dist/Chart.js",
"node_modules/fullcalendar/dist/fullcalendar.js",
"node_modules/quill/dist/quill.js",
"../../libs/react-component/main.min.js"
],
"styles": [
"node_modules/font-awesome/css/font-awesome.min.css",
"src/assets/theme/primeng-omega-theme.css",
"src/assets/theme/primeng.min.css",
"node_modules/primeicons/primeicons.css",
"node_modules/fullcalendar/dist/fullcalendar.min.css",
"node_modules/quill/dist/quill.snow.css",
"node_modules/nanoscroller/bin/css/nanoscroller.css",
{
"input": "src/custom-theme.scss",
"inject": true
},
"src/styles2.scss",
"node_modules/ngx-toastr/toastr.css",
"src/styles.css",
"src/app.scss"
],
"assets": [
"src/assets",
"src/favicon.png",
{
"glob": "/*",
"input": "../node_modules/ngx-monaco-editor/assets/monaco",
"output": "./assets/monaco/min/"
}
]
}
},
"serve-ssr": {
"builder": "@nguniversal/builders:ssr-dev-server",
"options": {
"browserTarget": "appname-frontend:build",
"serverTarget": "appname-frontend:server"
},
"configurations": {
"production": {
"browserTarget": "appname-frontend:build:production",
"serverTarget": "appname-frontend:server:production"
}
}
},
"prerender": {
"builder": "@nguniversal/builders:prerender",
"options": {
"browserTarget": "appname-frontend:build:production",
"serverTarget": "appname-frontend:server:production",
"routes": [
"/"
]
},
"configurations": {
"production": {},
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.e2e.ts"
}
],
"optimization": true
}
}
},
"cypress-run": {
"builder": "@briebug/cypress-schematic:cypress",
"options": {
"devServerTarget": "appname-frontend:serve"
},
"configurations": {
"production": {
"devServerTarget": "appname-frontend:serve:production"
}
}
},
"cypress-open": {
"builder": "@briebug/cypress-schematic:cypress",
"options": {
"devServerTarget": "appname-frontend:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "appname-frontend:serve:production"
}
}
}
}
},
"appname-frontend-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@briebug/cypress-schematic:cypress",
"options": {
"devServerTarget": "appname-frontend:serve-coverage",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "appname-frontend:serve-coverage:production"
}
}
},
"e2e-ci": {
"builder": "@briebug/cypress-schematic:cypress",
"options": {
"browser": "chrome",
"devServerTarget": "appname-frontend:serve-coverage",
"headless": true,
"watch": false
},
"configurations": {
"production": {
"devServerTarget": "appname-frontend:serve-coverage:production"
}
}
},
"cypress-run": {
"builder": "@briebug/cypress-schematic:cypress",
"options": {
"devServerTarget": "appname-frontend-e2e:serve"
},
"configurations": {
"production": {
"devServerTarget": "appname-frontend-e2e:serve:production"
}
}
},
"cypress-open": {
"builder": "@briebug/cypress-schematic:cypress",
"options": {
"devServerTarget": "appname-frontend-e2e:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "appname-frontend-e2e:serve:production"
}
}
}
}
}
},
"schematics": {
"@schematics/angular:component": {
"prefix": "",
"style": "scss"
},
"@schematics/angular:directive": {
"prefix": ""
}
}
}

πŸ”₯ Exception or Error

I noticed this error in my command line when first loading the application from the build


Error: Uncaught (in promise): Error: NG04002
Error: NG04002
    at ApplyRedirects.noMatchError (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/@angular/router/fesm2015/router.mjs:3659:16)
    at selector (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/@angular/router/fesm2015/router.mjs:3641:28)
    at onError (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:51)
    at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
    at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at OperatorSubscriber2.Subscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at resolvePromise (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/zone.js/fesm2015/zone-node.js:1142:31)
    at resolvePromise (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/zone.js/fesm2015/zone-node.js:1096:17)
    at apply (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/zone.js/fesm2015/zone-node.js:1209:17)
    at _ZoneDelegate.invokeTask (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/zone.js/fesm2015/zone-node.js:406:31)
    at Object.onInvokeTask (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/@angular/core/fesm2015/core.mjs:26254:33)
    at _ZoneDelegate.invokeTask (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/zone.js/fesm2015/zone-node.js:405:60)
    at Zone2.runTask (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/zone.js/fesm2015/zone-node.js:178:47)
    at drainMicroTaskQueue (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/zone.js/fesm2015/zone-node.js:585:35) {
  rejection: RuntimeError: NG04002
      at ApplyRedirects.noMatchError (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/@angular/router/fesm2015/router.mjs:3659:16)
      at selector (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/@angular/router/fesm2015/router.mjs:3641:28)
      at onError (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:51)
      at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
      at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
      at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
      at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
      at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
      at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
      at OperatorSubscriber2.Subscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30) {
    code: 4002
  },
  promise: ZoneAwarePromise [Promise] {
    __zone_symbol__state: 0,
    __zone_symbol__value: RuntimeError: NG04002
        at ApplyRedirects.noMatchError (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/@angular/router/fesm2015/router.mjs:3659:16)
        at selector (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/@angular/router/fesm2015/router.mjs:3641:28)
        at onError (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:51)
        at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
        at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
        at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
        at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
        at OperatorSubscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
        at OperatorSubscriber2.error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
        at OperatorSubscriber2.Subscriber2._error (/Users/jacobjohn/appname/frontend-web/web_app_hybrid/apps/angularapp/dist/server/webpack:/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30) {
      code: 4002
    }
  },
  zone:  Zone {
    _parent: Zone {
      _parent: null,
      _name: '',
      _properties: {},
      _zoneDelegate: [_ZoneDelegate]
    },
    _name: 'angular',
    _properties: { isAngularZone: true },
    _zoneDelegate:  _ZoneDelegate {
      _taskCounts: [Object],
      zone: [Circular *1],
      _parentDelegate: [_ZoneDelegate],
      _forkZS: null,
      _forkDlgt: null,
      _forkCurrZone: null,
      _interceptZS: null,
      _interceptDlgt: null,
      _interceptCurrZone: null,
      _invokeZS: [Object],
      _invokeDlgt: [_ZoneDelegate],
      _invokeCurrZone: [Circular *1],
      _handleErrorZS: [Object],
      _handleErrorDlgt: [_ZoneDelegate],
      _handleErrorCurrZone: [Circular *1],
      _scheduleTaskZS: [Object],
      _scheduleTaskDlgt: [_ZoneDelegate],
      _scheduleTaskCurrZone: [Circular *1],
      _invokeTaskZS: [Object],
      _invokeTaskDlgt: [_ZoneDelegate],
      _invokeTaskCurrZone: [Circular *1],
      _cancelTaskZS: [Object],
      _cancelTaskDlgt: [_ZoneDelegate],
      _cancelTaskCurrZone: [Circular *1],
      _hasTaskZS: [Object],
      _hasTaskDlgt: [_ZoneDelegate],
      _hasTaskDlgtOwner: [Circular *2],
      _hasTaskCurrZone: [Circular *1]
    }
  },
  task: ZoneTask {
    _zone:  Zone {
      _parent: [Zone],
      _name: 'angular',
      _properties: [Object],
      _zoneDelegate: [_ZoneDelegate]
    },
    runCount: 0,
    _zoneDelegates: null,
    _state: 'notScheduled',
    type: 'microTask',
    source: 'Promise.then',
    data: ZoneAwarePromise [Promise] {
      __zone_symbol__state: 0,
      __zone_symbol__value: [RuntimeError]
    },
    scheduleFn: undefined,
    cancelFn: undefined,
    callback: [Function (anonymous)],
    invoke: [Function (anonymous)]
  }
}

🌍 Your Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 14.2.1
Node: 14.20.0
Package Manager: npm 6.14.17
OS: darwin x64

Angular: 14.2.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, localize, material, platform-browser
... platform-browser-dynamic, platform-server, router, upgrade

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.1
@angular-devkit/build-angular   14.2.1
@angular-devkit/core            14.2.1
@angular-devkit/schematics      14.2.1
@angular/cli                    14.2.1
@angular/flex-layout            14.0.0-beta.40
@nguniversal/builders           14.1.0
@nguniversal/express-engine     14.1.0
@schematics/angular             14.2.1
rxjs                            7.5.6
typescript                      4.6.4

Let me know if anyone needs any more configs please.

alan-agius4 commented 2 years ago

Thanks for reporting this issue. However, you didn't provide sufficient information for us to understand and reproduce the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

jacobjohn-transitiv commented 2 years ago

Thanks for your response @alan-agius4. I'll try to make a minimal repro shortly

jacobjohn-transitiv commented 2 years ago

Figured out the issue on my end. For those in a similar situation, here what's I did

The base url for all the api calls are stored on our env file and during the deployment process, the production tokens are replaced in azure (currently the prod env file base urls are tokens that get replaced during the deployment/release process in azure, such as #{base_url}.

The task that handles the replacement of tokens looks for the files dist/browser/main-es2015.*.js and dist/browser/main-es15.*.js and does a find and replace. Since updating to 14, those files are no longer created and instead dist/browser/main.*.js is created and used for the app.

These tokens were never replaced, so the base url got replaced by the host url, as it should, by angular's http. Once I updated the deployment config on azure to look for the correct main file, and not the differential loading files, the deployed app's api calls were functioning as it should.

angular-automatic-lock-bot[bot] commented 1 year ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.