-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Is there any guide how to enable SSR for Angular6 template? #5423
Comments
I just went through this last week upgrading an Angular 6 project with SSR. Documentation is still evolving (see dotnet/AspNetCore.Docs#7310) - aside from the changes in #581, you'll need the following pieces in place: angular.json - add a new project that builds via @angular-devkit/build-angular:server. Note that below, I'm specifically not optimizing my server bundle and bundling all dependencies to avoid having to ship my node_modules folder to production pending optimization fixes upstream in angular (angular/angular-cli#8616).
package.json - update build scripts to reflect the following
Also in package.json, make sure you have a devDependencies for @angular-devkit/build-angular. Note that as of right now, you'll need version 0.7.0-rc.0 to enable --watch functionality to rebuild your server bundle during development. See angular/angular-cli#11415. Production SSR should work with @angular-devkit/build-angular 0.6.8, but you won't get --watch functionality during development. Startup.cs - one minor deviation from the switch to @angular-devkit/build-angular. The file produced by @angular-devkit/build-angular is different, so adjust main.bundle.js to main.js
|
@esoderquist I seem to get the following error:
|
@esoderquist Thanks for your answer. I've followed your instructions and got an error
here is a link with changes https://github.com/vasyliv/angular6/tree/angular-server |
@vasyliv I suspect you're hitting aspnet/JavaScriptServices#1619, which leads to development-time SSR failing to detect that @angular-devkit/build-angular has finished building. PR aspnet/JavaScriptServices#1620 should address the root issue. |
@esoderquist I've added the script to avoid the flag
after click F5 the project works fine. @SteveSandersonMS Could you clarify the version of |
@vasyliv I started getting that error when I updated to dotnet core 2.1.1 from 2.1.0. Worked after refresh as well. Did not get the error on 2.1.0 and seems to work on 2.1.2 as well. |
@c3mohamn yes, you are right but do all time the refresh of the page is a bad idea, I can't say that it works fine. |
up |
Up |
up |
1 similar comment
up |
The task to update the documentation has been on just moved to another sprint for the 4th time. |
I've followed the documentation from the .Net Core docs along with what @esoderquist has suggested but I'm still getting This is incredibly frustrating because the app that I'm building will need to utilise SSR for SEO and potentially performance purposes. I guess I should just plough on without SSR and wait for the official ASP.Net document update (if that ever happens...) |
getting:
looks like its hashtags and CSR for me :( |
Is there anyone who can create a repo with a sample of asp.net core + angular 6 and SSR enabled , I'm stuck in this since last week! |
There is the one of @vasyliv https://github.com/vasyliv/angular6/tree/angular-server I try a bunch let me know if you have any luck. |
@jfborie yes, you are right, i have this issue in angular 5 and angular 6 but it is not critical for me, due to the reason that it's the issue with fiddler and postman, if i load by browser it will work fine, to sum up in prod on your site it will work fine too. |
@jfborie thanks, I used that sample and it helped but my app was not still working, after 10 days! I finally found out that the problem was reading a config file in my AppModule from assets folder and in the server It was not available so I had no results! |
@HesamKashefi What config file are you referring to? The |
@jasonhulbert I have a path to a configuration file saved in my
and inside my configService:
this was my problem! I still get that timeout error on first load in debug but it just needs a |
We periodically close 'discussion' issues that have not been updated in a long period of time. We apologize if this causes any inconvenience. We ask that if you are still encountering an issue, please log a new issue with updated information and we will investigate. |
Is there any guide how to enable SSR for Angular6 template?
The text was updated successfully, but these errors were encountered: