'How to fix "Error at XMLHttpRequest.send angular universal"

Аfter compiling the application, I get this error several times enter image description here

text error:

ERROR Error

    at XMLHttpRequest.send (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:169324:19)
    at Observable.rxjs__WEBPACK_IMPORTED_MODULE_1__.Observable [as _subscribe] (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:19023:17)
    at Observable._trySubscribe (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:154852:25)
    at Observable.subscribe (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:154838:22)
    at DoOperator.call (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:162245:23)
    at Observable.subscribe (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:154833:31)
    at scheduleTask (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:97108:32)
    at Observable.rxjs__WEBPACK_IMPORTED_MODULE_7__.Observable [as _subscribe] (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:97170:13)
    at Observable._trySubscribe (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:154852:25)
    at Observable.subscribe (C:\Users\seva-\projects\pileuniversal\dist\pileuniversal\server\main.js:154838:22)

I'm not importing anything in app.server.module after creating ssr Was problem with localStorage and window with DOM, but solition is exist



Solution 1:[1]

I face the very same problem. You may check this article

https://www.infragistics.com/products/ignite-ui-angular/angular/components/general/framework-and-features/ssr-rendering.html

The issue for XMLHttpRequest.send comes from the fact that this "object", does not exist for the Node server.

I advise You to track where Your error comes from. In my case, it was from ngx-translate module, which was trying to get the JSON files via XMLHttpRequest. To solve the issue You have to:

  1. Identify from where this call has been made
  2. Apply interceptors which will handle the request properly

In my case, I follow this tutorial: https://itnext.io/angular-universal-how-to-add-multi-language-support-68d83f6dfc4d

I add the interceptor and solve the issue.

Hope that helps

Solution 2:[2]

I Had this problem, and just now I changed the URL for my requests

from

'/assets/data/products.json'

to

'http://localhost...'.

it worked for me

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Aleksandar Jockovic