Skip to content

ReferenceError: XMLHttpRequest is not defined #41311

@rabraghib

Description

@rabraghib

🐞 Bug report

What modules are related to this issue?

  • aspnetcore-engine
  • builders
  • common
  • express-engine
  • hapi-engine

Is this a regression?

IDK 😕😕

Description

I am trying to make an http request via a pipe & I get the error below.

🔬 Minimal Reproduction

Here is a repo that show the bug: https://github.com/rabraghib/ng-universal-bug
the app setted up with the minimale possible changes using the CLI.

# generate new angular app
ng new ng-universal-bug --routing
# add angular universal
ng add @nguniversal/express-engine
# generate home module and route
ng g m home --route home --module app.module.ts
# generate http call pipe
ng g pipe home/httpCall

then I made some changes to let the pipe to make an http call to the given url .
& use it in home.component.html

🔥 Exception or Error


ERROR ReferenceError: XMLHttpRequest is not defined
    at BrowserXhr.build (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:150834:9)
    at Observable._subscribe (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:150868:41)       
    at Observable._trySubscribe (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:60530:25)     
    at Observable.subscribe (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:60516:22)
    at innerSubscribe (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:173928:23)
    at MergeMapSubscriber._innerSub (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:42626:105)
    at MergeMapSubscriber._tryNext (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:42620:14)  
    at MergeMapSubscriber._next (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:42603:18)     
    at MergeMapSubscriber.next (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:54386:18)      
    at Observable._subscribe (...\ng-universal-bug\dist\ng-universal-bug\server\main.js:131030:20) 

🌍 Your Environment

# ng version
Angular CLI: 11.2.5
Node: 12.18.0
OS: win32 x64

Angular: 11.2.6
... animations, common, compiler, compiler-cli, core, forms    
... platform-browser, platform-browser-dynamic, platform-server
... router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------      
@angular-devkit/architect       0.1102.5
@angular-devkit/build-angular   0.1102.5
@angular-devkit/core            11.2.5
@angular-devkit/schematics      11.2.5
@angular/cli                    11.2.5
@nguniversal/builders           11.2.1
@nguniversal/express-engine     11.2.1
@schematics/angular             11.2.5
@schematics/update              0.1102.5
rxjs                            6.6.6
typescript                      4.1.5

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: common/httpIssues related to HTTP and HTTP Clientstate: has PRtype: bug/fix

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions