View source does not display dynamic content in angular universal

Viewed 404

My angular app, which is an ssr, calls an API to get the product name, then I display it in the H1 tag like below

<h1> {{product.name}} </h1>

but When I check my view source page (ctrl + u ) the tag is empty. I think It is because SSR creates html template without waiting for API call. the Problem is: "When ssr sends me html, I want to make sure the h1 tag is not empty so that a crawler can find it for SEO purposes." I search about it but cant find any solution.

1 Answers

Is your angular app a PWA? Then this would be normal.

Is the page SSR'ed when you do shift + F5. Then everything is okay, and you don't have to worry.

Otherwise, there's a big chance that your production server doesn't allow webrequests during SSR, and you will need to use something equivalent to the SupplyData method in ASP.NET Core.

Related