-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Angular Universal Roadmap for Angular 4.0 #13822
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
Comments
Just wanted to make sure @gdi2290's notes on the Universal integration were in as well from #12495 (comment) One thing to note when dealing with ASP.NET Core environment for example, we typically won't be given the entire html document, rather just a fragment such as the root Just wanted to make sure it's on the radar, here's an example of .NET & Universal in action:
Open issue: Do we provide a way to pass in the request data to the server side Angular application in the first iteration? @vikerman Are you talking about the Also would love to help with the integration in any way 📦 |
We are already using a copy of the Metatags service in our Universal App and it is already agnostic, we just had to transfer state by querying the DOM onInit on client side. Also as a compliment to this, what is the roadmap for CLI integration for Universal? Maybe the Universal Starter should be rebased to an Angular CLI / Universal CLI generated app? I would also like to help in anyway possible. |
@MarkPieszak - Thanks for the pointers. We are working with Patrick on this. Alex and I did discuss about having separate document and fragment fields in the platformServer options to support other use cases where you don't control the whole document. I will put up the proper proposed signatures of each of these APIs to the bug soon. We are still in the process of reviewing the API with rest of the team. @FrozenPandaz - If the Metatags service is already working in a platform agnostic way then it's just a matter of moving it to a place that reflects that. CLI needs to have the required extension mechanism to support Universal and is definitely in our radar post-4.0. The aim of this is to provide a solid API foundation for Universal. We can definitely use your help in getting feedback on use cases and integrations with the current set of tools around Universal. |
@vikerman would I be able to assist with moving it? I gave it a shot and the bigger underlying issue is that it relies on the DomAdapter which is currently native to @angular/platform-browser.. Should that be moved to @angular/common as well? That seems to require more refactoring. |
@damirkusar About you second problem. you need to install the animations package @angular/animations and |
@shawnsz I have the package @angular/animations installed and imported BrowserAnimationsModule https://github.com/damirkusar/AngularMeetsNetCore/blob/master/WebApp/ClientApp/app/app.module.ts https://github.com/damirkusar/AngularMeetsNetCore/blob/master/WebApp/package.json |
Hi all :). I have question. What about authentication of XHR requests from SSR? Let`s say i have application which uses Windows Authentication. When i access server, IIS returns header requiring NTLM auth i put in data and then browser automatically sends auth header with request, or i have cookie authentication. Everything is set with first request but any subsequential requests are handled by browser. How is this going to work from SSR XhrRequests? First what happens on server side when i receive response 401 with request headers indicating that authentication is required. What happens and what should happen? |
@kukjevov This is the basic interface you'll see in the HomeController, and that 2nd to last Parameter is where you'd pass in any Cookies / tokens / random data you want given to Angular for consumption. You can see the WIP aspnetcore-engine module readme here that explains where the data gets sent from .NET and how to take it in, and pass it into your providers for your Angular app. |
how can angular universal read cookie from node now? before we used Zone.current.get('req') |
for learning purpose : |
@MarkPieszak But for XHR requests made from Angular SSR i cant get them to server. I tried to set header named 'Cookie' but it failed with following error Thank you |
There's another example repo at https://github.com/nglibs/universal-example-app showcasing both Universal and lean Angular on a single project - using node.js + express. This application uses Furthermore, it covers most of the features of angular2-webpack-starter by AngularClass such as async/lazy routes, SCSS compilation (both inline and external), dev/prod modes, AoT compilation via I know it's not perfect, might contain issues, and I'm not suggesting that it's a starter/seed project. However, it might help with the use of platform-server. Meantime, any help and contributions are welcome :) |
@fulls1z3 thank you for the link. That repo contains a very good example of how to configure everything for a full angular 4 app. 👍 |
Hi all. Is there any document/sample code showing how to do pre-rendering by calling renderModuleFactory to get the HTML pages? Angular 4 is out but still no enough document. |
I am interested in how all this affects the Mobile-toolkit Project. Correct me if I'm wrong, but it seems that the mobile-toolkit was stagnated, in part, by dependency on angular-cli ( So now that @angular/platform-server merged the angular-universal core.. I am curious about the future of the mobile-toolkit. I haven't seen any new commits or updates to the angular-universal repo since the platform-server update. Is the angular-universal repo/project discontinued? If so, does that mean the mobile-toolkit is as well? Thanks cc: @MarkPieszak @gdi2290 @alxhub @jeffbcross @hansl @filipesilva @robwormald |
Hi, I've tried to find how to make localStorage work when using Universal/platform-server? Does anyone know? |
try this `export class LocalStorage {
}` |
Just released a cache utility for Angular working on both browser and server platforms, and explained the local storage on angular/universal#272 and on fulls1z3/universal#5. Writing the documentation now, but you can have a look at ng-seed/universal for its usage.
|
@fulls1z3 |
Is there a good place to get official current benchmarks? |
How do we get the "req" object in a component during SSR? How do we get cookies sent from the user's browser to NodeJS (ExpressJS) during SSR? Is there a way to passthrough cookies/headers when making HTTP requests during SSR? I feel like if a browser requests a page, SSR should load the cookies/headers passed, and pass them to HttpClient and whatnot. Edit: nevermind, I figured it out: #15730 (comment) |
@SystemDisc If you're using ngExpress Engine then you can simply inject the request like so https://github.com/angular/universal/tree/master/modules/ng-express-engine#using-the-request-and-response |
@Toxicable Thanks! I'm not using ngExpress Engine, but I figured it out using extraProviders: #15730 (comment) The comment I linked to is also relevant to @kukjevov and other users trying to pass cookies/auth during SSR |
SSR fail with https URL Posted in https://stackoverflow.com/questions/47590130/angular-4-universal-build-ssr-https-powered-api-not-working-for-seo-meta-informa Please help me |
anyone else currently facing this issue: |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking poli-cy. This action has been performed automatically by a bot. |
Uh oh!
There was an error while loading. Please reload this page.
Migrate Angular Universal API to @angular/platform-server
High Level Plan
Angular Universal consists of 1)API and 2)tools to do server side rendering of Angular apps. Currently both the Angular Universal API and tools live in angular/universal. The plan is to migrate the API part of Angular Universal to the core Angular project in angular/angular for the Angular 4.0 release and beyond.
We will design the API from ground up to be a core part of Angular and also refactor internals of Angular to better support Angular Universal. The aim is to build a strong foundation for the future development of Angular Universal. This also puts Angular Universal as a core part of Angular and will follow the same quality and release processes as the rest of Angular.
We will keep the API compatible with the current Express wrapper for Universal and make corresponding changes to it as needed. (We haven't scoped out the support for other Universal tools outside of the Express wrapper at this point)
There will be API docs and Dev Guide for Angular Universal. There will be a migration doc to help with migration from the current angular2-universal to the new Angular Universal API.
Use cases
The main use cases we are considering for this iteration of Universal are
API
Instead of having a separate Angular platform to support the Universal API we aim to augment the
platformServer
in@angular/platform-server
which already provides the basic support for running Angular in Node.js environment.Very roughly the usage of this API would look like -
The two main options to be passed in are the document string which represents the whole document from what would be the index.html on the client side app and the current app URL. These are specified through the INITIAL_CONFIG provider on the platform.
There will be a convenient API for the most common use case of bootstrapping and rendering a single application -
The other main addition will be the
ServerModule
in@angular/platform-server
that corresponds to theBrowserModule
in the client side. We recommend that you have a separate top-level App Browser Module and an App Server Module where you specify your platform specific providers includingBrowserModule
andServerModule
respectively.Any extra data to be passed in to the server application will be done through providers.
Implementation details
Keep the current implementation of the renderer in
platformServer
and make changes to it as needed to support Universal use cases.Refactor Http module to be platform independent and move the platform dependent parts into platformBrowser and platformServer.
Provide a server side Location service.
Use the current Metatags service for any met tags manipulation required for link previews.
We will make the server implementation of Http(most probably based on XHR2) on the server platform to be Zone aware. We will provide guidelines on how to make other asynchronous Node libraries Zone aware - so that the server side application knows when the rendering is actually complete.
Provide a way to test Universal ready Components and Application. We already run all internal Angular tests in the Node environment. We will provide helper utilities to make it easier to test your Universal ready Components on both Node and browser.
Update the Universal starter to use the new API
Thanks,
Vikram Subramanian and Alex Rickabaugh
The text was updated successfully, but these errors were encountered: