{"id":332527,"date":"2022-04-28T15:00:16","date_gmt":"2022-04-28T15:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=332527"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=332527","title":{"rendered":"<span>Angular Universal: \u0440\u0430\u0431\u043e\u0442\u0430 \u0432 \u043a\u0440\u0443\u043f\u043d\u043e\u043c e-commerce<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0414\u0440\u0443\u0436\u043a\u043e\u0432, \u044f \u0442\u0438\u043c\u043b\u0438\u0434 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0423\u0442\u043a\u043e\u043d\u043e\u0441 \u041e\u043d\u043b\u0430\u0439\u043d. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0435\u043c \u043f\u043e\u043b\u0435\u0437\u0435\u043d Angular Universal \u0432 e-commerce \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043a\u0430\u043a \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0438\u0434 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430, \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u0438 \u0448\u0430\u0433\u0438 \u043f\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u043a\u0440\u043e\u044e \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b Universal. \u0421\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435 \u0437\u043d\u0430\u0435\u0442 SSR \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0430\u0439\u0442 \u0441 \u043d\u0443\u043b\u044f,<\/p>\n<\/li>\n<li>\n<p>\u0437\u043d\u0430\u043a\u043e\u043c \u0441 Angular \u0438 \u0445\u043e\u0447\u0435\u0442 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c SSR,<\/p>\n<\/li>\n<li>\n<p>\u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 Angular Universal,<\/p>\n<\/li>\n<li>\n<p>\u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0440\u0443\u043f\u043d\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u0430\u0436\u043d\u043e SEO.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e Angular Universal \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u043c\u0430\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 e-commerce \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u044e\u0430\u043d\u0441\u044b. \u0427\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0431\u044b\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043d\u0430\u043c\u0438, \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u0430 \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 SSR.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f Angular Universal\u00a0<\/h2>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 Angular \u043e\u0442\u0434\u0430\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0430\u0437\u043e\u0432\u0443\u044e index.html \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f SEO \u043f\u0443\u0441\u0442\u0430\u044f \u2014 \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0433 app-root \u0438 \u0441c\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 \u0441\u0442\u0438\u043b\u0438.\u00a0<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0445 \u0440\u043e\u0431\u043e\u0442\u043e\u0432 \u042f\u043d\u0434\u0435\u043a\u0441 \u0438 Google \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. Google \u0443\u043c\u0435\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c JavaScript \u043a\u043e\u0434: \u043e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443,\u00a0 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0441\u044e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443, \u0434\u0435\u043b\u0430\u0435\u0442 api \u0432\u044b\u0437\u043e\u0432\u044b, \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0435\u0451. \u041c\u044b \u0436\u0435 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u042f\u043d\u0434\u0435\u043a\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442. \u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 index.html \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0435\u0433\u043e, \u043a\u0430\u043a \u0435\u0441\u0442\u044c. \u0422\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u0431\u044b\u043b\u043e \u0432\u0430\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Universal.<\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 Angular Universal<\/h2>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c Angular Universal \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d <a href=\"https:\/\/angular.io\/guide\/universal\" rel=\"noopener noreferrer nofollow\"><u>\u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/u><\/a>:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 ng add @nguniversal\/express-engine<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b.\u00a0<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b:<\/p>\n<ul>\n<li>\n<p>server.ts \u2013 \u043b\u043e\u0433\u0438\u043a\u0430 express \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>tsconfig.server.json \u2013 \u043a\u043e\u043d\u0444\u0438\u0433 TS \u0434\u043b\u044f SSR<\/p>\n<\/li>\n<li>\n<p>src\/main.server.ts\u00a0<\/p>\n<\/li>\n<li>\n<p>src\/app\/app.server.module.ts<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 angular.json \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b:<\/p>\n<ul>\n<li>\n<p>\u0412 projects > utkonos > architect > build > options > outputPath \u043f\u0443\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u0441 &#171;dist\/utkonos&#187; \u043d\u0430 \u00abdist\/utkonos\/browser\u00bb<\/p>\n<\/li>\n<li>\n<p>&#171;server&#187;\u00a0\u00a0\u00a0 <\/p>\n<\/li>\n<li>\n<p>&#171;serve-ssr&#187;<\/p>\n<\/li>\n<li>\n<p>&#171;prerender&#187;<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 packaje.json \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b:<\/p>\n<ul>\n<li>\n<p>&#171;dev:ssr&#187;: &#171;ng run utkonos:serve-ssr&#187; \u2013 dev \u0441\u0431\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438,<\/p>\n<\/li>\n<li>\n<p>&#171;serve:ssr&#187;: &#171;node dist\/utkonos\/server\/main.js&#187; \u2013 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430 SSR,<\/p>\n<\/li>\n<li>\n<p>&#171;build:ssr&#187;: &#171;ng build &amp;&amp; ng run utkonos:server&#187; \u2013 \u0441\u0431\u043e\u0440\u043a\u0430 SSR,<\/p>\n<\/li>\n<li>\n<p>&#171;prerender&#187;: &#171;ng run utkonos:prerender&#187; \u2013 \u043f\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 main.ts \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 AppModule.<\/p>\n<p>\u0412 app-routing.module.ts \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u043e initialNavigation: &#8216;enabledBlocking&#8217; \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u043b\u044f SSR \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0445\u0443\u043a\u0438 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430.<\/p>\n<p>\u0412 app.modules.ts \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a BrowserModule: withServerTransition({ appId: &#8216;serverApp&#8217; }) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 TransferState\u2019\u043e\u043c \u2014 \u043e \u043d\u0451\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c dev-\u0441\u0431\u043e\u0440\u043a\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <strong>npm run dev:ssr<\/strong> \u0438, \u0435\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435\u0442, \u0442\u043e \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:4200\" rel=\"noopener noreferrer nofollow\"><u>http:\/\/localhost:4200<\/u><\/a> \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432\u0430\u0448 \u0441\u0430\u0439\u0442. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e SSR \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 JavaScript \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u2014 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0430\u0439\u0442, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 node.js, \u043a\u0430\u043a\u0438\u043c \u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0440\u043e\u0431\u043e\u0442 \u2014 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c HTML \u0438 CSS \u0431\u0435\u0437 JavaScript.<\/p>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 c DOM \u0432 Angular Universal<\/h3>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0432 \u0441\u0440\u0435\u0434\u0435 node.js \u043d\u0435\u0442 DOM, \u0438 \u043f\u043e\u0442\u043e\u043c\u0443 \u043b\u044e\u0431\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u043d\u0438\u043c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u0443\u0442 \u043e\u0448\u0438\u0431\u043a\u0443. \u0420\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 Domino <a href=\"https:\/\/www.npmjs.com\/package\/domino\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.npmjs.com\/package\/domino<\/u><\/a>, \u043e\u043d \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 DOM API. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 server.ts:<\/p>\n<pre><code>\/\/ SSR DOM import { domino } from 'domino'; Object.assign(global, domino.impl);  import { fs } from 'fs';  \/\/ index from browser folder const browserFolder = join(__dirname, '..\/browser'); const template = fs.readFileSync(join(browserFolder, 'index.html')).toString(); const window = domino.createWindow(template);  \/\/ mock global['window'] = window; global['document'] = window.document;<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u044f\u043c\u044b\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u043e \u0432\u0441\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u044b\u043c api \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 InjectionToken. \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u0435\u043d \u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SSR, \u0442.\u043a. \u0437\u0430 \u0441\u0447\u0451\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0447\u0438\u0441\u0442\u043e\u0442\u0443 \u043a\u043e\u0434\u0430 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 window.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b window.ts \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 WINDOW:<\/p>\n<p>Window.ts<\/p>\n<pre><code>import { DOCUMENT } from '@angular\/common'; import { inject, InjectionToken } from '@angular\/core';   export const WINDOW = new InjectionToken&lt;Window>('An abstraction over global window object', {   factory: () => {     const { defaultView } = inject(DOCUMENT);       if (!defaultView) {       throw new Error('Window is not available');     }       return defaultView;   }, });<\/code><\/pre>\n<p>\u0418 \u0434\u0430\u043b\u0435\u0435 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:  <\/p>\n<pre><code> constructor(     @Inject(WINDOW) private window: Window,  ) {}<\/code><\/pre>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 API \u0431\u044d\u043a\u0435\u043d\u0434\u0430<\/h3>\n<p>\u0411\u0440\u0430\u0443\u0437\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c api \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0442\u043e\u0442 \u0436\u0435 \u0434\u043e\u043c\u0435\u043d, \u044d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u044d\u043a\u0435\u043d\u0434\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0435\u0440\u0435\u0437 nginx. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 express \u0441\u0435\u0440\u0432\u0435\u0440. \u0427\u0442\u043e\u0431\u044b \u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0430\u043b api \u0441\u0435\u0440\u0432\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0443 \u0441 \u043f\u0440\u043e\u043a\u0441\u0438. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/www.npmjs.com\/package\/express-http-proxy\" rel=\"noopener noreferrer nofollow\"><u>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 express-http-proxy<\/u><\/a>:\u00a0<\/p>\n<pre><code>import * as proxy from 'express-http-proxy';   \/\/ From environment variables const apiUrl = ConfigHelper.getApiURLForServer();   \/\/ The Express app is exported so that it can be used by serverless Functions. export function app(): express.Express {   const server = express();     \/\/ Proxy to back for client requests   server.use('\/api', proxy(apiUrl, { proxyReqPathResolver: (req: Request) =>      '\/api' + req.url   }));<\/code><\/pre>\n<h3>\u0421\u0442\u0430\u0442\u0438\u043a\u0430<\/h3>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Angular Universal \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.\u00a0<\/p>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 <strong>npm run build:ssr<\/strong>, \u043e\u043d\u0430 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 package.json. \u0414\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438: ng build &amp;&amp; ng run utkonos:server.\u00a0<\/p>\n<p>\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u043f\u043e\u043a \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u043e\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 angular.json:\u00a0<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 projects > utkonos > architect > build > options > OutputPath<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 projects > utkonos > architect > server > options > OutputPath<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438 browser \u0438 server. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/48c\/c47\/f2f\/48cc47f2f30c9d0e0a47427188376338.png\" width=\"248\" height=\"273\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/48c\/c47\/f2f\/48cc47f2f30c9d0e0a47427188376338.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0424\u0430\u0439\u043b server\/main.js \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f node.js \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. \u0424\u0430\u0439\u043b\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 browser \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0441\u043c\u043e\u0433 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 browser, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0438\u0434\u043b\u0432\u0430\u0440:<\/p>\n<pre><code>  \/\/ Serve static files from \/browser   server.get(     '*.*',     express.static(browserFolder, {       maxAge: '1y',     })   );<\/code><\/pre>\n<h2>\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 Angular Universal<\/h2>\n<h3>\u0412\u044b\u0431\u043e\u0440 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430:<\/p>\n<ul>\n<li>\n<p>SSR (server-side rendering) \u2014 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 api \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>SSG (static site generation) \u2014 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0438 \u043e\u0442\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043f\u043e \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0443.<\/p>\n<\/li>\n<li>\n<p>CSR (client-side rendering) \u2014 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u0439\u0442.<\/p>\n<\/li>\n<li>\n<p>ISR (incremental static regeneration) \u2014 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 SSR \u0438 SSG: \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u044d\u0448\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043e\u0442\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e. \u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u043d\u0430 \u0438\u0437 \u043a\u044d\u0448\u0430.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0412\u044b\u0431\u043e\u0440 \u0432\u0438\u0434\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0430 \u0441\u0430\u0439\u0442\u0430.<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e, \u0442\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 SSR. \u041d\u043e \u043d\u0430\u0434\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u0439\u0442\u0435, \u0433\u0434\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e, \u0438 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c SSG. \u041f\u043b\u044e\u0441\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0434\u0430\u0451\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e. \u041c\u0438\u043d\u0443\u0441 \u2014 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0440\u0435\u043d\u0434\u0435\u0440.<\/p>\n<p>E-commerce \u0441\u0430\u0439\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446 (\u0443 \u043d\u0430\u0441 \u0438\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0442\u044b\u0441\u044f\u0447), \u0438\u0445 \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0430 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u043f\u043e\u0434\u0445\u043e\u0434 ISR \u2014 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u041f\u0440\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<h3>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\/\u0441\u0435\u0440\u0432\u0435\u0440 \u0432 TypeScript<\/h3>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f SSR \u0438 \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f SEO \u043d\u0435 \u0432\u0430\u0436\u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430 \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438.\u00a0<\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b isPlatformBrowser \u0438 isPlatformServer.<\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code>import { isPlatformBrowser, isPlatformServer } from '@angular\/common'; import { Injectable, Inject, PLATFORM_ID } from '@angular\/core';   @Injectable({ providedIn: 'root' }) export class BrowserApiService {   private _isBrowser = isPlatformBrowser(this.platformId);   private _isServer = isPlatformServer(this.platformId);     constructor(     @Inject(PLATFORM_ID) private platformId: object,   ) {   }     isBrowser(): boolean {     return this._isBrowser;   }     isServer(): boolean {     return this._isServer;   } }<\/code><\/pre>\n<h3>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\/\u0441\u0435\u0440\u0432\u0435\u0440 \u0432 HTML<\/h3>\n<p>\u0411\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f SSR \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e HTML \u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443:<\/p>\n<pre><code>import { Directive, TemplateRef, ViewContainerRef } from '@angular\/core'; import { BrowserApiService } from '@shared\/services\/browser-api.service';   @Directive({   selector: '[clientSideRendering]', }) export class ClientSideRenderingDirective {   constructor(private viewContainer: ViewContainerRef, private browserApi: BrowserApiSupportService, private tplRef: TemplateRef&lt;any>) {     this.viewContainer.clear();     if (this.browserApi.isBrowser()) {       this.viewContainer.createEmbeddedView(this.tplRef, {});     }   } }<\/code><\/pre>\n<h3>TransferState<\/h3>\n<p>\u0414\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430 node.js \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f api \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b api \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.\u00a0<\/p>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c TransferState: \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0443\u0436\u043d\u043e \u0434\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u0441\u0435\u043f\u0442\u043e\u0440\u0430 \u2014 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u044b\u0439. \u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 api \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u044d\u0448\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0442\u0432\u0435\u0442, \u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c.<\/p>\n<p>\u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0432 \u0442\u0435\u043b\u0435 intex.html \u0432 \u0442\u0435\u0433\u0435 &lt;script id=&#187;serverApp-state&#187; type=&#187;application\/json&#187;> \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 {\u043a\u043b\u044e\u0447 \u0437\u0430\u043f\u0440\u043e\u0441\u0430: \u043e\u0442\u0432\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430}\u00a0\u00a0\u00a0<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h3>\u041a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u0430<\/h3>\n<p>\u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0435\u043d\u0434\u0435\u0440\u0430 \u0438 api \u0432\u044b\u0437\u043e\u0432\u043e\u0432. \u0412 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f ISR <a href=\"https:\/\/scully.io\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/scully.io<\/u><\/a>. \u041c\u044b \u0432 \u0423\u0442\u043a\u043e\u043d\u043e\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Kubernets \u0434\u043b\u044f \u0441\u0440\u0435\u0434\u044b \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f. \u041e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u043e\u0432 node.js \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438 Angular Universal, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u044d\u0448 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d. \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 Redis.\u00a0<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0442\u0430\u043a\u0430\u044f, \u0447\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u043e GET \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u044d\u0448\u0435, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0435\u0451 \u043d\u0435\u0442 \u2014 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u0435\u0448.\u00a0\u00a0<\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441 api \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 SSR \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0438\u0437-\u043f\u043e\u0434 \u0433\u043e\u0441\u0442\u0435\u0432\u043e\u0439 \u0443\u0447\u0451\u0442\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u043e\u0442\u0432\u0435\u0442\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c api \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 node.js \u043a \u0431\u044d\u043a\u0435\u043d\u0434\u0443 \u043e\u043d \u0441\u043f\u0435\u0440\u0432\u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u0435\u0448\u0435.<\/p>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Redis \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u0434\u0445\u043e\u0434 ISR \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446.<\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0438 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 Redis \u044f \u043e\u043f\u0438\u0448\u0443 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0442\u0435\u043c\u0430.<\/p>\n<h3>\u041a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u043a\u0438 \u0432 CDN<\/h3>\n<p>\u041d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u043c\u0438\u043c\u043e GET \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0441\u0442\u0430\u0442\u0438\u043a\u0443: JS, CSS \u0444\u0430\u0439\u043b\u044b, \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u0442\u0434.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c, \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 CDN \u0441\u0435\u0440\u0432\u0438\u0441\u0435. \u041c\u044b \u043a\u044d\u0448\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u043c \u0432\u0441\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0432 CDN \u0442\u043e\u0436\u0435 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f. \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0443 \u043c\u0435\u043d\u044f \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0440\u044f\u0434 \u0442\u0435\u043c \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432)\u00a0<\/p>\n<h3>\u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 RxJS<\/h3>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 RxJS \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e, \u0438 \u0442\u043e\u0440\u043c\u043e\u0437\u044f\u0449\u0443\u044e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c, \u0442\u043e \u0432 \u0441\u0440\u0435\u0434\u0435 node.js \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e.\u00a0<\/p>\n<p>\u041d\u0435\u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u0438 \u0441\u0431\u043e\u0440\u0449\u0438\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0445 \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043e\u0442\u043f\u0438\u0441\u043a\u0430\u043c\u0438. \u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432 \u0445\u0443\u043a\u0435 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 OnDestroy.\u00a0<\/p>\n<p>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043e\u0442\u043f\u0438\u0441\u043a\u0438 \u043c\u043d\u043e\u0433\u043e, \u043a\u0430\u0436\u0434\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 \u043f\u0443\u0442\u044c.\u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0443\u0442\u0435\u0447\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 node.js, \u0435\u0441\u043b\u0438 \u043e\u043d \u0434\u043e\u0441\u0442\u0438\u0433 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432 Kubernets \u043f\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e:<\/p>\n<pre><code>  private runMonitoring(): void {     setInterval(() => this.checkNodeHealth(), this.nodeJSMonitoringInterval);   }      private checkNodeHealth(): void {     const heapUsed = this.getHeapUsed();     if (heapUsed > this.heapLimit) {       process.exit();     }   }      private getHeapUsed(): number {     return process.memoryUsage().heapUsed \/ 1024 \/ 1024;   }<\/code><\/pre>\n<p>\u041d\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0438 \u043d\u0430\u0434\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0443\u0442\u0435\u0447\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c Chrome DevTools \u2014 \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f <a href=\"https:\/\/developer.chrome.com\/docs\/devtools\/memory-problems\/\" rel=\"noopener noreferrer nofollow\"><u>Fix memory problems<\/u><\/a>.\u00a0<\/p>\n<h3>\u0421\u0436\u0430\u0442\u0438\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430<\/h3>\n<p>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043a\u043e\u043d\u0442\u0435\u043d\u0442, \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u044f \u0435\u0433\u043e \u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/www.npmjs.com\/package\/compression\" rel=\"noopener noreferrer nofollow\"><u>compression<\/u><\/a>, \u044d\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/web.dev\/reduce-network-payloads-using-text-compression\/\" rel=\"noopener noreferrer nofollow\"><u>Minify and compress network payloads<\/u><\/a>.\u00a0<\/p>\n<pre><code>import * as compression from 'compression';  export function app(): express.Express {   const server = express();   server.use(compression());<\/code><\/pre>\n<h3>\u0424\u0438\u043b\u044c\u0442\u0440 \u0443\u0440\u043b\u043e\u0432<\/h3>\n<p>\u0427\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043d\u0435 \u0432\u0430\u0436\u043d\u0430 \u0434\u043b\u044f SEO (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0440\u0437\u0438\u043d\u0430), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0430\u043a\u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 index.html.<\/p>\n<h3>\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 Angular<\/h3>\n<p>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0432 SSR. \u041f\u0440\u0438 \u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 api \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f HTML. \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0433\u043e\u0442\u043e\u0432\u0430. \u041d\u0430 \u043d\u0430\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u043b\u0438\u044f\u044e\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0432\u0451\u0440\u0441\u0442\u043a\u0438 \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (setTimout, api \u0437\u0430\u043f\u0440\u043e\u0441\u044b), \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u0432 \u0437\u043e\u043d\u0435.  \u00a0<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0430 \u043d\u0435\u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435, \u0442\u043e \u043d\u0430\u0434\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 <a href=\"https:\/\/developer.chrome.com\/docs\/devtools\/\" rel=\"noopener noreferrer nofollow\"><u>Chrome DevTools<\/u><\/a>. \u041f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439: \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/developer.chrome.com\/docs\/devtools\/evaluate-performance\/\" rel=\"noopener noreferrer nofollow\"><u>Analyze runtime performance<\/u><\/a> \u0438 WebVitals <a href=\"https:\/\/www.seonews.ru\/analytics\/web-vitals-gotovimsya-k-izmeneniyu-algoritma-google-v-iyune-2021\/\" rel=\"noopener noreferrer nofollow\"><u>Web Vitals: \u0433\u043e\u0442\u043e\u0432\u0438\u043c\u0441\u044f \u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 Google \u0432 \u0438\u044e\u043d\u0435 2021<\/u><\/a>.\u00a0<\/p>\n<p>\u0415\u0449\u0451 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0430\u043d\u0430\u043b\u0438\u0437 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043c\u044b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043f\u043e\u0434\u0440\u044f\u0434\u0447\u0438\u043a\u043e\u0432 \u043f\u043e \u0447\u0430\u0442-\u0431\u043e\u0442\u0443 \u0438 \u0440\u0435\u043a\u043b\u0430\u043c\u0435, \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 Google Tag Manager. \u0415\u0441\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043d\u0435 \u0432\u0430\u0436\u0435\u043d \u0434\u043b\u044f SEO, \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0445 \u043f\u0440\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043c\u044b \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0445 \u0432 SSR.<\/p>\n<h2>\u041f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b Angular Universal<\/h2>\n<p>Angular Universal \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 SEO, \u0441\u0430\u0439\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u0442\u0435\u043d \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432. \u0427\u0442\u043e\u0431\u044b \u0441\u0430\u0439\u0442 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u043d\u0436\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 SSR, \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0432\u0451\u0440\u0441\u0442\u043a\u0443, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c, \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u0433\u0438, \u0443\u043b\u0443\u0447\u0448\u0430\u0442\u044c Web Vitals \u0438 \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0435\u0449\u0435 \u2014 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430.<\/p>\n<p>\u0412\u0430\u0448 \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0435\u0437 Angular Universal \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0437\u0436\u0435. \u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0442.\u043a. \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c window, localstorage \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 api \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0436\u0435 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c SSR \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p>\u041f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0432 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 SSR. \u041f\u0440\u0438 ISR \u043f\u043e\u0434\u0445\u043e\u0434\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u0430, \u0438 \u0432 \u043a\u044d\u0448\u0435, \u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u043e, \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0431\u0430\u043b\u0430\u043d\u0441 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.\u00a0<\/p>\n<p>\u041f\u043b\u044e\u0441 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u043c api \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0435 \u0432 SSR, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 TransferState.\u00a0<\/p>\n<p>\u0415\u0441\u0442\u044c \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0438\u0435\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043e\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 HTML \u0444\u0430\u0439\u043b, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c. \u041f\u043e\u0442\u043e\u043c \u0432\u0435\u0441\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0435\u0433\u0430 app-root \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f, \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e SPA. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0433\u0438\u0434\u0440\u0430\u0446\u0438\u044f. \u0415\u0441\u043b\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0430, \u0442\u043e \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442 \u00ab\u043c\u043e\u0440\u0433\u0430\u043d\u0438\u044f\u00bb \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<p>SSR \u043e\u0447\u0435\u043d\u044c \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d \u043a \u0443\u0442\u0435\u0447\u043a\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438. \u0415\u0441\u043b\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0438 \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c, \u0442\u043e \u0432 \u0441\u0440\u0435\u0434\u0435 node.js \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043e\u0442\u043f\u0438\u0441\u043a\u0430\u043c\u0438 \u0432 RxJS.\u00a0<\/p>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434 ISR \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u0435\u043d: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043b\u0433\u0438\u043c. \u0417\u0430\u0442\u043e \u043e\u043d \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 SSR \u0438 SSG, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430.<\/p>\n<p>\u0415\u0449\u0435 \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e Angular Universal \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f SSR \u0438 \u0447\u0430\u0441\u0442\u043e \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 SSR \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0435\u043c\u0430\u043b\u043e \u0443\u0441\u0438\u043b\u0438\u0439.<\/p>\n<h2>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u044b\u0432\u043e\u0434\u0430<\/h2>\n<p>Angular Universal \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e e-commerce \u0441\u0430\u0439\u0442\u0430, \u043e\u043d \u0434\u0430\u0451\u0442 SEO \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0421\u0430\u043c Universal \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435, \u0438 \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 Angular \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u0442 \u0432\u0441\u0435 \u0443\u0441\u0438\u043b\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c.\u00a0<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0438 \u043e\u0431\u0448\u0438\u0440\u043d\u044b\u0445 \u0442\u0435\u043c \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u044d\u0448\u0435\u043c \u0432 Redis \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432 CDN \u2014 \u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u043e\u0441\u0432\u044f\u0449\u0443 \u0441\u0432\u043e\u0438 \u0431\u0443\u0434\u0443\u0449\u0438\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b. \u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0438 \u0434\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447!)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/663518\/\"> https:\/\/habr.com\/ru\/post\/663518\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0414\u0440\u0443\u0436\u043a\u043e\u0432, \u044f \u0442\u0438\u043c\u043b\u0438\u0434 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u0423\u0442\u043a\u043e\u043d\u043e\u0441 \u041e\u043d\u043b\u0430\u0439\u043d. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0447\u0435\u043c \u043f\u043e\u043b\u0435\u0437\u0435\u043d Angular Universal \u0432 e-commerce \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043a\u0430\u043a \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0438\u0434 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430, \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u0438 \u0448\u0430\u0433\u0438 \u043f\u043e \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0440\u0430\u0441\u043a\u0440\u043e\u044e \u043f\u043b\u044e\u0441\u044b \u0438 \u043c\u0438\u043d\u0443\u0441\u044b Universal. \u0421\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435 \u0437\u043d\u0430\u0435\u0442 SSR \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0430\u0439\u0442 \u0441 \u043d\u0443\u043b\u044f,<\/p>\n<\/li>\n<li>\n<p>\u0437\u043d\u0430\u043a\u043e\u043c \u0441 Angular \u0438 \u0445\u043e\u0447\u0435\u0442 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c SSR,<\/p>\n<\/li>\n<li>\n<p>\u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 Angular Universal,<\/p>\n<\/li>\n<li>\n<p>\u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u0440\u0443\u043f\u043d\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432\u0430\u0436\u043d\u043e SEO.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e Angular Universal \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u043c\u0430\u043b\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 e-commerce \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0433\u0434\u0435 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u044e\u0430\u043d\u0441\u044b. \u0427\u0430\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0431\u044b\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043d\u0430\u043c\u0438, \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u0430 \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u043e\u043c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 SSR.<\/p>\n<h2>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f Angular Universal\u00a0<\/h2>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 Angular \u043e\u0442\u0434\u0430\u0435\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0430\u0437\u043e\u0432\u0443\u044e index.html \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f SEO \u043f\u0443\u0441\u0442\u0430\u044f \u2014 \u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0433 app-root \u0438 \u0441c\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 \u0441\u0442\u0438\u043b\u0438.\u00a0<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0445 \u0440\u043e\u0431\u043e\u0442\u043e\u0432 \u042f\u043d\u0434\u0435\u043a\u0441 \u0438 Google \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. Google \u0443\u043c\u0435\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c JavaScript \u043a\u043e\u0434: \u043e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443,\u00a0 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0441\u044e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443, \u0434\u0435\u043b\u0430\u0435\u0442 api \u0432\u044b\u0437\u043e\u0432\u044b, \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u0435\u0451. \u041c\u044b \u0436\u0435 \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u042f\u043d\u0434\u0435\u043a\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442. \u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 index.html \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0435\u0433\u043e, \u043a\u0430\u043a \u0435\u0441\u0442\u044c. \u0422\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u043c \u0431\u044b\u043b\u043e \u0432\u0430\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Universal.<\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 Angular Universal<\/h2>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c Angular Universal \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u043f\u0438\u0441\u0430\u043d <a href=\"https:\/\/angular.io\/guide\/universal\" rel=\"noopener noreferrer nofollow\"><u>\u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/u><\/a>:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 ng add @nguniversal\/express-engine<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b.\u00a0<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b:<\/p>\n<ul>\n<li>\n<p>server.ts \u2013 \u043b\u043e\u0433\u0438\u043a\u0430 express \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p>tsconfig.server.json \u2013 \u043a\u043e\u043d\u0444\u0438\u0433 TS \u0434\u043b\u044f SSR<\/p>\n<\/li>\n<li>\n<p>src\/main.server.ts\u00a0<\/p>\n<\/li>\n<li>\n<p>src\/app\/app.server.module.ts<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 angular.json \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b:<\/p>\n<ul>\n<li>\n<p>\u0412 projects > utkonos > architect > build > options > outputPath \u043f\u0443\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u0441 &#171;dist\/utkonos&#187; \u043d\u0430 \u00abdist\/utkonos\/browser\u00bb<\/p>\n<\/li>\n<li>\n<p>&#171;server&#187;\u00a0\u00a0\u00a0 <\/p>\n<\/li>\n<li>\n<p>&#171;serve-ssr&#187;<\/p>\n<\/li>\n<li>\n<p>&#171;prerender&#187;<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 packaje.json \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b:<\/p>\n<ul>\n<li>\n<p>&#171;dev:ssr&#187;: &#171;ng run utkonos:serve-ssr&#187; \u2013 dev \u0441\u0431\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438,<\/p>\n<\/li>\n<li>\n<p>&#171;serve:ssr&#187;: &#171;node dist\/utkonos\/server\/main.js&#187; \u2013 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430 SSR,<\/p>\n<\/li>\n<li>\n<p>&#171;build:ssr&#187;: &#171;ng build &amp;&amp; ng run utkonos:server&#187; \u2013 \u0441\u0431\u043e\u0440\u043a\u0430 SSR,<\/p>\n<\/li>\n<li>\n<p>&#171;prerender&#187;: &#171;ng run utkonos:prerender&#187; \u2013 \u043f\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 main.ts \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 AppModule.<\/p>\n<p>\u0412 app-routing.module.ts \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u043e initialNavigation: &#8216;enabledBlocking&#8217; \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u043b\u044f SSR \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0431\u0435\u0437 \u043d\u0435\u0433\u043e \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0445\u0443\u043a\u0438 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0430.<\/p>\n<p>\u0412 app.modules.ts \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a BrowserModule: withServerTransition({ appId: &#8216;serverApp&#8217; }) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 TransferState\u2019\u043e\u043c \u2014 \u043e \u043d\u0451\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043d\u0438\u0436\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c dev-\u0441\u0431\u043e\u0440\u043a\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <strong>npm run dev:ssr<\/strong> \u0438, \u0435\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435\u0442, \u0442\u043e \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:4200\" rel=\"noopener noreferrer nofollow\"><u>http:\/\/localhost:4200<\/u><\/a> \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432\u0430\u0448 \u0441\u0430\u0439\u0442. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e SSR \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 JavaScript \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u2014 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u0430\u0439\u0442, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 node.js, \u043a\u0430\u043a\u0438\u043c \u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u0440\u043e\u0431\u043e\u0442 \u2014 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c HTML \u0438 CSS \u0431\u0435\u0437 JavaScript.<\/p>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 c DOM \u0432 Angular Universal<\/h3>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u0432 \u0441\u0440\u0435\u0434\u0435 node.js \u043d\u0435\u0442 DOM, \u0438 \u043f\u043e\u0442\u043e\u043c\u0443 \u043b\u044e\u0431\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u043d\u0438\u043c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u0443\u0442 \u043e\u0448\u0438\u0431\u043a\u0443. \u0420\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 Domino <a href=\"https:\/\/www.npmjs.com\/package\/domino\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.npmjs.com\/package\/domino<\/u><\/a>, \u043e\u043d \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 DOM API. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 server.ts:<\/p>\n<pre><code>\/\/ SSR DOM import { domino } from 'domino'; Object.assign(global, domino.impl);  import { fs } from 'fs';  \/\/ index from browser folder const browserFolder = join(__dirname, '..\/browser'); const template = fs.readFileSync(join(browserFolder, 'index.html')).toString(); const window = domino.createWindow(template);  \/\/ mock global['window'] = window; global['document'] = window.document;<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u044f\u043c\u044b\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u043e \u0432\u0441\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u044b\u043c api \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 InjectionToken. \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u0435\u043d \u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f SSR, \u0442.\u043a. \u0437\u0430 \u0441\u0447\u0451\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0434\u0430\u0451\u0442 \u043d\u0430\u043c \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0447\u0438\u0441\u0442\u043e\u0442\u0443 \u043a\u043e\u0434\u0430 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 window.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0444\u0430\u0439\u043b window.ts \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0432 \u043d\u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 WINDOW:<\/p>\n<p>Window.ts<\/p>\n<pre><code>import { DOCUMENT } from '@angular\/common'; import { inject, InjectionToken } from '@angular\/core';   export const WINDOW = new InjectionToken&lt;Window>('An abstraction over global window object', {   factory: () => {     const { defaultView } = inject(DOCUMENT);       if (!defaultView) {       throw new Error('Window is not available');     }       return defaultView;   }, });<\/code><\/pre>\n<p>\u0418 \u0434\u0430\u043b\u0435\u0435 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:  <\/p>\n<pre><code> constructor(     @Inject(WINDOW) private window: Window,  ) {}<\/code><\/pre>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 API \u0431\u044d\u043a\u0435\u043d\u0434\u0430<\/h3>\n<p>\u0411\u0440\u0430\u0443\u0437\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c api \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0442\u043e\u0442 \u0436\u0435 \u0434\u043e\u043c\u0435\u043d, \u044d\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u044d\u043a\u0435\u043d\u0434\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0435\u0440\u0435\u0437 nginx. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 express \u0441\u0435\u0440\u0432\u0435\u0440. \u0427\u0442\u043e\u0431\u044b \u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0430\u043b api \u0441\u0435\u0440\u0432\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0438\u0434\u043b\u0432\u0430\u0440\u0443 \u0441 \u043f\u0440\u043e\u043a\u0441\u0438. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/www.npmjs.com\/package\/express-http-proxy\" rel=\"noopener noreferrer nofollow\"><u>\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 express-http-proxy<\/u><\/a>:\u00a0<\/p>\n<pre><code>import * as proxy from 'express-http-proxy';   \/\/ From environment variables const apiUrl = ConfigHelper.getApiURLForServer();   \/\/ The Express app is exported so that it can be used by serverless Functions. export function app(): express.Express {   const server = express();     \/\/ Proxy to back for client requests   server.use('\/api', proxy(apiUrl, { proxyReqPathResolver: (req: Request) =>      '\/api' + req.url   }));<\/code><\/pre>\n<h3>\u0421\u0442\u0430\u0442\u0438\u043a\u0430<\/h3>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Angular Universal \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.\u00a0<\/p>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 <strong>npm run build:ssr<\/strong>, \u043e\u043d\u0430 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 package.json. \u0414\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438: ng build &amp;&amp; ng run utkonos:server.\u00a0<\/p>\n<p>\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u043f\u043e\u043a \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u043e\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 angular.json:\u00a0<\/p>\n<ul>\n<li>\n<p>\u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 projects > utkonos > architect > build > options > OutputPath<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 projects > utkonos > architect > server > options > OutputPath<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0432\u0435 \u043f\u0430\u043f\u043a\u0438 browser \u0438 server. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0424\u0430\u0439\u043b server\/main.js \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f node.js \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. \u0424\u0430\u0439\u043b\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 browser \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0441\u043c\u043e\u0433 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 browser, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043c\u0438\u0434\u043b\u0432\u0430\u0440:<\/p>\n<pre><code>  \/\/ Serve static files from \/browser   server.get(     '*.*',     express.static(browserFolder, {       maxAge: '1y',     })   );<\/code><\/pre>\n<h2>\u0423\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 Angular Universal<\/h2>\n<h3>\u0412\u044b\u0431\u043e\u0440 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430<\/h3>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430:<\/p>\n<ul>\n<li>\n<p>SSR (server-side rendering) \u2014 \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 api \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>SSG (static site generation) \u2014 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0438 \u043e\u0442\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043f\u043e \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u0443.<\/p>\n<\/li>\n<li>\n<p>CSR (client-side rendering) \u2014 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u0439\u0442.<\/p>\n<\/li>\n<li>\n<p>ISR (incremental static regeneration) \u2014 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 SSR \u0438 SSG: \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u044d\u0448\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043e\u0442\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e. \u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0434\u0430\u043d\u0430 \u0438\u0437 \u043a\u044d\u0448\u0430.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0412\u044b\u0431\u043e\u0440 \u0432\u0438\u0434\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0430 \u0441\u0430\u0439\u0442\u0430.<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e, \u0442\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 SSR. \u041d\u043e \u043d\u0430\u0434\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u0439\u0442\u0435, \u0433\u0434\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e, \u0438 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c SSG. \u041f\u043b\u044e\u0441\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0434\u0430\u0451\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e. \u041c\u0438\u043d\u0443\u0441 \u2014 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0440\u0435\u043d\u0434\u0435\u0440.<\/p>\n<p>E-commerce \u0441\u0430\u0439\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446 (\u0443 \u043d\u0430\u0441 \u0438\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0442\u044b\u0441\u044f\u0447), \u0438\u0445 \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0430 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u043f\u043e\u0434\u0445\u043e\u0434 ISR \u2014 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438. \u041f\u0440\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<h3>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\/\u0441\u0435\u0440\u0432\u0435\u0440 \u0432 TypeScript<\/h3>\n<p>\u0412 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f SSR \u0438 \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u044f SEO \u043d\u0435 \u0432\u0430\u0436\u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043d\u0430 \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438.\u00a0<\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b isPlatformBrowser \u0438 isPlatformServer.<\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code>import { isPlatformBrowser, isPlatformServer } from '@angular\/common'; import { Injectable, Inject, PLATFORM_ID } from '@angular\/core';   @Injectable({ providedIn: 'root' }) export class BrowserApiService {   private _isBrowser = isPlatformBrowser(this.platformId);   private _isServer = isPlatformServer(this.platformId);     constructor(     @Inject(PLATFORM_ID) private platformId: object,   ) {   }     isBrowser(): boolean {     return this._isBrowser;   }     isServer(): boolean {     return this._isServer;   } }<\/code><\/pre>\n<h3>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\/\u0441\u0435\u0440\u0432\u0435\u0440 \u0432 HTML<\/h3>\n<p>\u0411\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u043b\u044f SSR \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e HTML \u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0443:<\/p>\n<pre><code>import { Directive, TemplateRef, ViewContainerRef } from '@angular\/core'; import { BrowserApiService } from '@shared\/services\/browser-api.service';   @Directive({   selector: '[clientSideRendering]', }) export class ClientSideRenderingDirective {   constructor(private viewContainer: ViewContainerRef, private browserApi: BrowserApiSupportService, private tplRef: TemplateRef&lt;any>) {     this.viewContainer.clear();     if (this.browserApi.isBrowser()) {       this.viewContainer.createEmbeddedView(this.tplRef, {});     }   } }<\/code><\/pre>\n<h3>TransferState<\/h3>\n<p>\u0414\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430 node.js \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f api \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b api \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.\u00a0<\/p>\n<p>\u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c TransferState: \u0434\u043b\u044f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0443\u0436\u043d\u043e \u0434\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u0441\u0435\u043f\u0442\u043e\u0440\u0430 \u2014 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043d\u044b\u0439. \u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 api \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u044d\u0448\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0442\u0432\u0435\u0442, \u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c.<\/p>\n<p>\u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0437\u0430\u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0432 \u0442\u0435\u043b\u0435 intex.html \u0432 \u0442\u0435\u0433\u0435 &lt;script id=&#187;serverApp-state&#187; type=&#187;application\/json&#187;> \u0432 \u0432\u0438\u0434\u0435<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-332527","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332527","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=332527"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332527\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}