问题
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