Server side rendering using Angular 5 (Angular Universal) page source is not updating

可紊 提交于 2019-12-06 14:17:34

问题


I have working server side rendering project followed by Angular Universal guide. Eveything working fine except when I am navigating to other ulrs i still see first page (login page) source when hiting "view page source".

Any idea what this issue can be?

p.s. conten generated by prerender.ts also generates login screen source.


回答1:


View Page Source shows originally loaded HTML, later DOM is modified by angular, but it has no effect on originally loaded HTML.




回答2:


I recently had this problem too. It was something to do with the server proxy on an Apache server not rendering pages on other urls. However, everything was working on my localhost server.

example.com (rendering)
example.com/faq (rendering)
example.com/faq/general (not rendering)

If you are using Apache, configure your proxy settings in your virtualhost file

<VirtualHost *:80>
 ServerName example.com
 DocumentRoot /your/apache/files/htdocs

 ProxyRequests Off
 ProxyPreserveHost On
 ProxyVia Full
 <Proxy *>
  Require all granted
 </Proxy>

<Location /*>
      ProxyPass http://127.0.0.1:3000
      ProxyPassReverse http://127.0.0.1:3000
</Location>
<Location /faq/*>
      ProxyPass http://127.0.0.1:3000
      ProxyPassReverse http://127.0.0.1:3000
</Location>

</VirtualHost>

Restart your server and it should come up on your view page source.



来源:https://stackoverflow.com/questions/47137594/server-side-rendering-using-angular-5-angular-universal-page-source-is-not-upd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!