You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
Did anything ever happen with this? I am trying to sort out how to get http wired in. My XMLHttpRequest is not available. Not sure what the right path for getting http included in the universal is. Or if that is even the right path.
If you use the angular2-express-engine or angular2-hapi-engine, this part will be done for you, but if you are manually bootstrapping on the server, you will need to set the NodeXHRImpl yourself.
We are going to include this in the documentation for #258 so closing this issue.
@jeffwhelpley damn! Shame I didn't see your message before. Anyways... I am using angular2-express-engine and it wasn't working for me. So I created this: angular2-http-node_backend
@svallory if you are using Universal, you are going to want to use the default http with the Universal NodeXHRImpl provider. The reason is that in Universal we count the number of times http is called during a given server side request. We need to do this because it is the only want to know how long to wait before sending back the response (i.e. if there are 4 http calls during a given server side request, we have to wait for all 4 to resolve plus one change detection cycle before sending back the response.
@jeffwhelpley Just checked the code on Universal. I see you guys are using xhr2 package so you get a XmlHttpRequest object on node. THAT is what I replaced by implementing NodeBackend and NodeConnection using native node APIs to perform the request. It's a lighter impl and, if you want, we could bring it inside universal and remove the dependancy.
@gdi2290 I can. I'll work on it next weekend (it's carnival in Brazil :)). All I see in that file is NodeXhrImpl being imported and then exported inside a constant. I don't see it being used.
Since you mentioned templateUrl, currently relative URL's don't work. Is there a reason not to load it from FS when it's a relative URL?
Activity
simb commentedon Feb 5, 2016
Did anything ever happen with this? I am trying to sort out how to get http wired in. My XMLHttpRequest is not available. Not sure what the right path for getting http included in the universal is. Or if that is even the right path.
jeffwhelpley commentedon Feb 7, 2016
@simb check out this:
https://github.com/angular/universal/blob/master/modules/universal/server/src/platform/node.ts#L102
If you use the angular2-express-engine or angular2-hapi-engine, this part will be done for you, but if you are manually bootstrapping on the server, you will need to set the NodeXHRImpl yourself.
We are going to include this in the documentation for #258 so closing this issue.
svallory commentedon Feb 8, 2016
@jeffwhelpley damn! Shame I didn't see your message before. Anyways... I am using angular2-express-engine and it wasn't working for me. So I created this: angular2-http-node_backend
jeffwhelpley commentedon Feb 8, 2016
@svallory if you are using Universal, you are going to want to use the default http with the Universal NodeXHRImpl provider. The reason is that in Universal we count the number of times http is called during a given server side request. We need to do this because it is the only want to know how long to wait before sending back the response (i.e. if there are 4 http calls during a given server side request, we have to wait for all 4 to resolve plus one change detection cycle before sending back the response.
Let me know if you have any questions on this.
svallory commentedon Feb 9, 2016
@jeffwhelpley Just checked the code on Universal. I see you guys are using xhr2 package so you get a
XmlHttpRequestobject on node. THAT is what I replaced by implementingNodeBackendandNodeConnectionusing native node APIs to perform the request. It's a lighter impl and, if you want, we could bring it inside universal and remove the dependancy.I also see other problems:
NodeBackendandNodeConnectionstill usesBrowserXHRNodeXhrImplcallsHttp.get(shouldn't it be the other way around?)I'm still kind fresh on ng2 so bare with me if I got something wrong, ok?
PatrickJS commentedon Feb 9, 2016
@svallory can you make a PR to replace xhr2.
NodeXhrImplis used for templateUrl etc hereuniversal/modules/universal/server/src/platform/node.ts
Line 102 in 10443e9
svallory commentedon Feb 9, 2016
@gdi2290 I can. I'll work on it next weekend (it's carnival in Brazil :)). All I see in that file is
NodeXhrImplbeing imported and then exported inside a constant. I don't see it being used.Since you mentioned templateUrl, currently relative URL's don't work. Is there a reason not to load it from FS when it's a relative URL?
PatrickJS commentedon Feb 9, 2016
comment in the other issue #264 as op issue is unrelated.
angular-automatic-lock-bot commentedon Sep 4, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.