I am new to Angular. I just finished developing my angular web application. When I use ng serve to serve my application during production, everything works fine. I added angular universal. Now when I run any of npm run dev:ssr or npm run build:ssr && npm run serve:ssr, my application will refuse to open, throwing NetworkError response in the console. I noticed this error occurs for the number of times http requests where sent via class ‘constructors(){..}’. I have browsed through several solution but couldn’t get a clue of what I’m not doing right. My backend is developed with nodejs and express. I’ll appreciate any help I can get.
Here is a full example of the error response I always get in the console.
ERROR NetworkError
at XMLHttpRequest.send (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:200768:19)
at Observable._subscribe (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:19025:17)
at Observable._trySubscribe (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:186304:25)
at Observable.subscribe (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:186290:22)
at scheduleTask (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:105897:32)
at Observable._subscribe (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:105959:13)
at Observable._trySubscribe (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:186304:25)
at Observable.subscribe (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:186290:22)
at subscribeToResult (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:196385:23)
at MergeMapSubscriber._innerSub (C:\Users\MRBEN\Desktop\Angular\fxcore\dist\fxcore\server\main.js:191575:116)```
I am getting the same error. Try to remove
TransferHttpCacheModule
from yourapp.module
and create your own custom http transfer interceptor file.I made a file called
transfer-state.interceptor.ts
and then added it toapp.module
providers:[]
to handle this. The examples below will show how I hooked it up. I am not sure if this will definitely work for you but it did make that error go away for me.This is one version of a custom transfer state file but there are a few ways to do this if this one doesn’t work.
If you want to add custom cache to this you can by installing
memory-cache
but I haven’t tried that out yet. For more references these articles helped me out a lot and maybe they can help you too.https://itnext.io/angular-universal-caching-transferstate-96eaaa386198
https://willtaylor.blog/angular-universal-for-angular-developers/
https://bcodes.io/blog/post/angular-universal-relative-to-absolute-http-interceptor
If you haven’t you may need to add
ServerTransferStateModule
to your app.server.module file.good luck!
I was still getting this
ERROR NetworkError
but I found another way to make this error go away. I think this answer is relevant since I was getting the same error posted above. If this can help anyone with that same server error then that’s great.If the api request is made to the server
OnInit
when reloading checkisPlatformBrowser
first when usingng-universal
example.I was getting this same error trying to make server calls from the client before checking
isPlatformBrowser === true
firstOnInit
and this solved my problem. Hopefully this can help this bug.For reference this answer helped me squash this long standing bug. https://stackoverflow.com/a/46893433/4684183
Using absolute URLs for HTTP (data) requests on the server
https://angular.io/guide/universal#using-absolute-urls-for-http-data-requests-on-the-server
propecia results after 3 months – propecia before and after 3 months propecia sex
propecia topical gel – http://propechl.com/ hair medication propecia
generic tadalafil canada – mixing sildenafil and tadalafil buy tadalafil pills
Bvxbsk – Lowest price for viagra buy viagra louisiana
Stsxup – provigil for adhd Fekztl igcbvs
Ziitsk – cialis generique avis Exambj bjjnhw
Aerrri – zithropls.com Ctumis xffrca
Bmkjhh – technology research paper Qpdbkz nqoheq
Sffkfr – what does finasteride 5mg look like Nmtsxq slogyc
Qxmmqi – harmony gold max viagra Aejmfj zzvwzk
Vueclv – generic finasteride ndc Gbivxo gwscgs
Zktdrq – essays using quotes Ieehzo hzbpyp
Dpatic – sildenafil tadalafil Jaxcsz gaifnz
Qnzhcy – essay nurse Hxhclo tofhuh
Lvrktx – lasix 100mg Ubibra eevatc
Vfdryx – cheapest place to buy vardenafil Nzzpsh glzyal
Lqqqxd – silagra canada Pfdbib yecilt