I am trying to host local angular server with self-signed certificate.Certificate and key are generated using openSSL. Running openSSL server with them works as expected, Running empty node.js server with them works as well. However, when trying to run an angular project I get next results.
To use SSL I changed angular.json:
"options": {"ssl": true,"sslKey": "path/to/ssl/key.key","sslCert": "path/to/ssl/cert.crt" },
Server starts as expected and I recieve the ususal ng serve info in console:
Browser bundlesInitial chunk files | Names | Raw sizepolyfills.js | polyfills | 90.20 kB |main.js | main | 18.07 kB |styles.css | styles | 7.88 kB | | Initial total | 116.15 kBServer bundlesInitial chunk files | Names | Raw sizepolyfills.server.mjs | polyfills.server | 572.91 kB |main.server.mjs | main.server | 19.47 kB |server.mjs | server | 1.93 kB |Application bundle generation complete. [3.328 seconds]Watch mode enabled. Watching for file changes...NOTE: Raw file sizes do not reflect development server per-request transformations.➜ Local: https://localhost:4200/➜ press h + enter to show help
However, when trying to access https://localhost:4200/, the server is closed and I recieve the next error:
node:events:496 throw er; // Unhandled 'error' event ^TypeError: Cannot read properties of undefined (reading 'readable') at IncomingMessage._read (node:_http_incoming:214:19) at Readable.read (node:internal/streams/readable:737:12) at resume_ (node:internal/streams/readable:1255:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)Emitted 'error' event on IncomingMessage instance at: at emitErrorNT (node:internal/streams/destroy:169:8) at errorOrDestroy (node:internal/streams/destroy:238:7) at Readable.read (node:internal/streams/readable:739:7) at resume_ (node:internal/streams/readable:1255:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)Node.js v20.11.1
I put next code into server.ts to recieve error info:
process.on('uncaughtException', (err) => { console.error('Uncaught Exception:', err);});process.on('unhandledRejection', (reason, promise) => { console.error('Unhandled Rejection at:', promise, 'reason:', reason);});
and received next message when the server was closed:
Uncaught Exception: TypeError: Cannot read properties of undefined (reading 'readable') at IncomingMessage._read (node:_http_incoming:214:19) at Readable.read (node:internal/streams/readable:737:12) at resume_ (node:internal/streams/readable:1255:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)Uncaught Exception: TypeError: Cannot set properties of undefined (setting 'content-security-policy') at ServerResponse.setHeader (node:_http_outgoing:661:45) at Immediate.write (file:///D:/%D0%B4%D0%B7/7%D1%81%D0%B5%D0%BC%20%D1%81%D1%83%D0%BA%D1%86%D1%84%D0%B4%D1%88%D1%83%D0%B5%D0%BF%D1%84%D0%B6%D0%B4%D1%89%D1%88%D0%BA%D0%BF%D1%80%D0%B6%D1%89%D1%83%D1%88%D0%BA%D1%80%D0%BF%D0%B6%D1%89%D1%84%D1%88%D1%83%D0%BA%D1%80/%D0%B0%D0%BF%D0%BF%D0%B7/project/APPZ_front/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:41049:9) at process.processImmediate (node:internal/timers:480:21)
The error is replicated on a fresh angular project, with no changes applied to it. I could not find any similar errors online.
Versions installed:
$ ng version _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | | / ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | | /_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___| |___/Angular CLI: 19.0.1Node: 20.11.1Package Manager: npm 10.8.1OS: win32 x64Angular: 19.0.0... animations, cdk, common, compiler, compiler-cli, core, forms... material, platform-browser, platform-browser-dynamic... platform-server, routerPackage Version---------------------------------------------------------@angular-devkit/architect 0.1900.1@angular-devkit/build-angular 19.0.1@angular-devkit/core 19.0.1@angular-devkit/schematics 19.0.1@angular/cli 19.0.1@angular/ssr 19.0.1@schematics/angular 19.0.1rxjs 7.8.1typescript 5.6.3zone.js 0.15.0