0

I am working on server side rendering project followed by Angular Universal guide. Everything is working fine, except when I am navigating to other routes other than first page, I still see first page's source when hitting "view page source" in browser.

I have gone through this issue, but in my case routes are not under authorization.

Any idea why I cannot see page source of other routes?

3
  • This happens because you did not attach the code you have to the question Commented Feb 16, 2018 at 7:30
  • When you mean "navigating to other routes", do you mean by typing the adress directly in the browser, or by cliking links in your app? Commented Feb 16, 2018 at 8:54
  • @David navigating means by clicking links in my app. Commented Feb 16, 2018 at 8:55

2 Answers 2

0

That's normal behaviour. When you make the first request to the server, the page content will be rendered server side, which means that you'll be able to see that content if you see the page's source.

After that, when you navigate through your app's links, all content is rendered by javascript, with data fetched from server using ajax. As you are not changing page (it's a Single Page app) , the View source in the browser's page is never updated. If you type in directly the url of another route in the browser, you should get the corresponding content if you check the source

Sign up to request clarification or add additional context in comments.

2 Comments

I tried typing the url directly in browser, but again on viewing page source it gives the content of first page. Also some data which is coming from service call is also not updated on first page.
Its not working for me. Only static pages content are shown in view source. Rest are not shown. Docs are also not very helpful and not many threads regarding this issue. I wonder if people do prefer universal angular since its quite hard to implement
0

I solved this problem.In my project I have used Hash Location Strategy. Removing HashLocation Strategy allows me to view source code of other pages.

1 Comment

Hi, Can you provide your solution to the problem? I am not using hash location strategy in my project but still, the first-page source is the same with only app-root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.