New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceError: XMLHttpRequest is not defined #41311
Comments
This seems to be a problem with the What is happening here is that in the root injector we are setting angular/packages/platform-server/src/http.ts Line 140 in 5eb7f34
However this is overridden in the child injector when HttpClientModule is used in a lazy module because of https://github.com/angular/angular/blob/master/packages/common/http/src/module.ts#L163
I think the best solution for this would be to move the registration of angular/packages/common/http/src/module.ts Lines 162 to 163 in 5eb7f34
BrowserModule , similar to other Browser specific providers angular/packages/platform-browser/src/browser.ts Lines 69 to 91 in 5eb7f34
|
…gular#41313) With this change we move `XhrFactory` to the root entrypoint of `@angular/commmon`, this is needed so that we can configure `XhrFactory` DI token at a platform level, and not add a dependency between `@angular/platform-browser` and `@angular/common/http`. Currently, when using `HttpClientModule` in a child module on the server, `ReferenceError: XMLHttpRequest is not defined` is being thrown because the child module has its own Injector and causes `XhrFactory` provider to be configured to use `BrowserXhr`. Therefore, we should configure the `XhrFactory` at a platform level similar to other Browser specific providers. BREAKING CHANGE: `XhrFactory` has been moved from `@angular/common/http` to `@angular/common`. **Before** ```ts import {XhrFactory} from '@angular/common/http'; ``` **After** ```ts import {XhrFactory} from '@angular/common'; ``` Closes angular#41311 PR Close angular#41313
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
FYI, reopening this ticket based on #41909. |
For the record: the fix in #41313 has only been merged to master as it was a breaking change (although the breakage was mitigated in a follow up change, I believe) so this will only be fixed in v12, which has not yet been released. |
@JoostK great point, thanks for noticing this! @rabraghib could you please try to use |
yes Its fixed in v12 👌. TY for the swift response! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
What modules are related to this issue?
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.
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
🌍 Your Environment
The text was updated successfully, but these errors were encountered: