angulartypescripthttp-proxyhttp-proxy-middleware

TypeError: Cannot read properties of null (reading 'split')


I have an angular application which is throwing me this error when I try to access it.

TypeError: Cannot read properties of null (reading 'split')
    at required (/Users/.../node_modules/requires-port/index.js:13:23)
    at Object.common.setupOutgoing (/Users/.../node_modules/http-proxy/lib/http-proxy/common.js:101:7)
    at Array.stream (/Users/.../node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:127:14)
    at ProxyServer.<anonymous> (/Users/.../node_modules/http-proxy/lib/http-proxy/index.js:81:21)
    at HttpProxyMiddleware.middleware (.../node_modules/http-proxy-middleware/dist/http-proxy-middleware.js:22:32)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

This occurs when I try to run the app on Mac OS Catalina. When running on linux ubuntu the app works with no issues. This is how my environment looks like.

Angular CLI: 13.3.9
Node: 16.17.1
Package Manager: npm 8.15.0
OS: darwin x64


Angular CLI: 13.3.9
Node: 16.17.1
Package Manager: npm 8.15.0
OS: darwin x64

Angular: 13.2.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.1
@angular-devkit/build-angular   13.3.9
@angular-devkit/core            13.3.9
@angular-devkit/schematics      13.3.9
@angular/cdk                    13.3.9
@angular/cli                    13.3.9
@schematics/angular             13.3.9
rxjs                            7.5.6
typescript                      4.5.5
    

Solution

  • As pointed out by @Belouccio the link in 'target' should contain 'http'

    {
      "/api/*": {
        "target": "https://{{link}}",
        ...
    
      }
    }