0

I have created an Angular Universal app that consists of nested components. I need Prerender.io to return the Server-Side-Rendered HTML from my app but Prerender.io only returns the top level component tags and not the HTML within.

It seems that this happens to every Angular app (SRR or not). I would expect it to happen on a none-SSR page but not on SSR.

I followed the guidelines from prerender.io:

git clone https://github.com/prerender/prerender.git
cd prerender
npm install
node server.js

And then tried to go to:

http://localhost:3000/http://localhost:4000/test

The returned html I get is:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Documents SSR</title>
    <base href="/">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link rel="stylesheet" href="styles.3ff695c00d717f2d2a11.css">
    <style></style>
</head>

<body>
    <app-root _nghost-sc0="" ng-version="8.2.3" _nghost-serverapp-c0="">
        <router-outlet _ngcontent-serverapp-c0=""></router-outlet>
        <component1>
            <!---->
            <component2></component2>
        </component1>
    </app-root>

</body>

</html>

I would expect Prerender.io to render everything within component2 but as you see, I get nothing.

Am I missing a configuration somewhere or doesn't Prerender.io support Angular?

If I go directly to http://localhost:4000/test I get the full rendered HTML.

EDIT

It could look like Prerender.io doesn't wait for my last ajax call to be done before rendering?

1 Answer 1

1

Found the issue - don't use ShadowDom. My component2 was using encapsulation: ViewEncapsulation.ShadowDom. Removing that let Prerender give me the entire HTML.

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

Comments

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.